Sending to HID keyboard end causes reboot

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
seemefirst@gamil.com
Posts: 10
Joined: Mon Jul 08, 2019 9:15 pm

Sending to HID keyboard end causes reboot

Post by seemefirst@gamil.com » Thu Jul 11, 2019 8:56 pm

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)

User avatar
jimmo
Posts: 892
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: Sending to HID keyboard end causes reboot

Post by jimmo » Fri Jul 12, 2019 5:02 am

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?

seemefirst@gamil.com
Posts: 10
Joined: Mon Jul 08, 2019 9:15 pm

Re: Sending to HID keyboard end causes reboot

Post by seemefirst@gamil.com » Fri Jul 12, 2019 9:06 pm

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.

Post Reply