USB-device-midi is missing helper function to send SysEx
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- embedded-iot
Research direction
Start with the USB-device-midi implementation and the linked pull request #1068, comparing the proposed helper with the supplied example. Verify that the helper handles the three SysEx packet endings and reports a full transmit buffer as shown; done means the helper is integrated without duplicating existing MIDI transfer behavior.
Written by the indexing model from the issue text.
Description
I was using USB-device-midi to send MTC to the host, which is essentially SysEx. But was slowed by the missing helper function to send the packet of SysEx. Anyhow, I wrote one...
Full example script here:
https://github.com/orgs/micropython/discussions/18450#discussioncomment-15043069
Happy to share with the project
def send_sysex(self, p):
# start of SysEx packet
if len(p) > 3:
w = self._tx.pend_write()
if len(w) < 4:
return False # TX buffer is full. TODO: block here?
w[0] = 0x4 # _CIN_SYSEX_START
w[1] = p[0]
w[2] = p[1]
w[3] = p[2]
self._tx.finish_write(4)
self._tx_xfer()
p = p[3:]
# play out til end
while p:
if len(p) > 2:
w = self._tx.pend_write()
if len(w) < 4:
return False # TX buffer is full. TODO: block here?
w[0] = 0x7 # _CIN_SYSEX_END_3BYTE
w[1] = p[0]
w[2] = p[1]
w[3] = p[2]
self._tx.finish_write(4)
self._tx_xfer()
p = p[3:]
elif len(p) > 1:
w = self._tx.pend_write()
if len(w) < 4:
return False # TX buffer is full. TODO: block here?
w[0] = 0x6 # _CIN_SYSEX_END_2BYTE
w[1] = p[0]
w[2] = p[1]
w[3] = 0
self._tx.finish_write(4)
self._tx_xfer()
p = p[2:]
else:
w = self._tx.pend_write()
if len(w) < 4:
return False # TX buffer is full. TODO: block here?
w[0] = 0x5 # _CIN_SYSEX_END_1BYTE
w[1] = p[0]
w[2] = 0
w[3] = 0
self._tx.finish_write(4)
self._tx_xfer()
p = p[1:]
return True
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 4h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from micropython/micropython-lib
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficulty 1/5 Under an hour Newbie friendliness 72/100
micropython/micropython-lib#943 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
micropython/micropython-lib#931 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
micropython/micropython-lib#795 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#762 ·
All issues in micropython/micropython-lib
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
stephrobert/dsoxlab#238 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sublimehq/package_control#1780 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nwg-piotr/nwg-displays#145 ·