EDIT: I changed the title replacing “preempt” by "“use” as a solution allows to use ttymidi in several instances to translate serial data stream into MIDI data stream
Hello,
I try to connect the very compact Open Theremin V4 to the Zynthian V2.
Open Theremin V4 is an Atmega (Arduino-like) based project but is not possible to re-programm the USB serial interface into a genuine MIDI interface.
Hence I tried to involve ttymidi but it is already used by the DIN MIDI interface and it doesn’t seem to be multi instance.
The following command seems to work
systemctl stop mod-ttymidi
ttymidi -b 115200 -s /dev/ttyUSB0
But it would be nice if it was done automatically at ttyUSB* connection.
I went through some rules and systemd service research but ended with no elegant solution…
It is not that much about having enough serial ports. It is more about the program named “ttymidi” which changes the Serial data stream into a MIDI data stream. This program can only be used once at a time and is already taken by the DIN MIDI interface. You see…
Still searching but currently “ttymidi -b 115200 -s /dev/ttyUSB0” without stoping existing service using ttymidi will end with an errror message.
In my use case, I am not using MIDI DIN and USB MIDI through Serial at the same time. Then a preemption could be enough: taking ttymidi from MIDI DIN at USB connection and give it back to MIDI DIN at USB disconnection.
Yes, I used “ls /dev/tty*” before to get list of serial ports.
The message I get with “ttymidi -b 115200 -s /dev/ttyUSB0” is clearly saying that ttymidi is already used.
Add 2 new rules in “/etc/udev/rules.d/99-serial-usb.rules” (create this file if it doesn’t exist)
#ttymidi at USB serial port connection #connect
ACTION==“add”, SUBSYSTEM==“tty”, ENV{DEVNAME}==“/dev/ttyUSB[0-9]”, TAG+=“systemd”, ENV{SYSTEMD_WANTS}+=“hairlessUSBttymidi@$env{DEVNAME}.service”