Page 1 of 1

Sending to HID keyboard end causes reboot

Posted: Thu Jul 11, 2019 8:56 pm
by seemefirst@gamil.com
Here is my code that shows the problem of rebooting. Reboot happens when 378*2 = 756 characters sent to Keyboard end. I am testing this on Nucleo-L476RG. Any idea what causes this problem.

boot.py:

Code: Select all

# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal
import pyb
#pyb.main('main.py') # main script to run after this one
#pyb.usb_mode('VCP+MSC') # act as a serial and a storage device
pyb.usb_mode('VCP+HID', hid=pyb.hid_keyboard) 
main.py:

Code: Select all

hid = pyb.USB_HID()
print("start sending!")
while (True):
	for c in range(1000):
		hid.send((0,0,0x04,0,0,0,0,0))
		pyb.delay(10)
		hid.send((0,0,0,0,0,0,0,0))
		pyb.delay(10)
		hid.send((0,0,0x05,0,0,0,0,0))
		pyb.delay(10)
		hid.send((0,0,0,0,0,0,0,0))
		pyb.delay(10)
		print(str(c))
	hid.send((0,0,0x28,0,0,0,0,0))
	pyb.delay(10)
	hid.send((0,0,0,0,0,0,0,0))
	pyb.delay(10)
	pyb.delay(1000)

Re: Sending to HID keyboard end causes reboot

Posted: Fri Jul 12, 2019 5:02 am
by jimmo
Sorry I know this isn't particularly helpful, but FWIW this code works fine for me on a Pyboard 1.1 (STM32F405RGT6) talking to a Linux host. No reboots.

What else is different about your setup?

Re: Sending to HID keyboard end causes reboot

Posted: Fri Jul 12, 2019 9:06 pm
by seemefirst@gamil.com
I checked the prebuilt versions and everything was fine i.e. no reboot. Then I pulled the latest code built it again and everything is fine now. There must have been something different about my environment. Thanks for testing.