SerialPort problems in SC on Linux?

Hello everyone

I have recently started experimenting with Serial for the first time directly in SuperCollider and experiencing some trouble with the SerialPort object. Sometimes (rarely) it works fine, most of the time though sclang hangs when I init the object. It’s just really wonky is all. That said, I am not convinced it is SuperCollider’s fault so I just want to hear out everyone else who use SC on Linux if they experience similar issues? I see no open issues on Github concerning SerialPort but Sean Cotteril mentions it here:
in which he writes “… SuperCollider’s USB Serial implementation on Linux being fairly poor.” Can anyone shed some light on this?

Thanks a lot!

Ah and to add to the complexity, some stuff needed to be done in the Teensy to make Linux be a bit more cheery about my Serial input:
Now I can more consistently monitor the serial input but SC is not very happy about it

It seems I partly fixed this by not specifying the baud rate in the SerialPort object.
Until now I got errors like this:

ERROR: Primitive '_SerialPort_Open' failed.
caught exception 'set_option: Invalid argument' in primitive in method SerialPort:prOpen
Instance of SerialPort {    (0x5569231fe588, gc=E8, fmt=00, flg=00, set=02)
  instance variables [4]
    dataptr : nil
    semaphore : instance of Semaphore (0x55692327ac08, size=2, set=2)
    isOpen : false
    doneAction : nil
PATH: /home/mads/code/mcu/serial2cv/scd/serial-receiver.scd
		arg this = <instance of PrimitiveFailedError>
		arg this = nil
		arg error = <instance of PrimitiveFailedError>
		arg this = <instance of Thread>
		arg error = <instance of PrimitiveFailedError>
		arg this = <instance of PrimitiveFailedError>
		arg this = <instance of SerialPort>
		arg this = <instance of SerialPort>
		arg args = [*8]
	< closed FunctionDef >  (no arguments or variables)
		arg this = <instance of Interpreter>
		var res = nil
		var func = <instance of Function>
		var code = "~port ="/dev..."
		var doc = <instance of Document>
		var ideClass = nil
		arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Primitive '_SerialPort_Open' failed.
caught exception 'set_option: Invalid argument' in primitive in method SerialPort:prOpen
RECEIVER: a SerialPort

When runnning ~port ="/dev/ttyACM0", 115200);

But remove the baud rate argument (which teensy apparantly doesn’t care about) and it seems to work slightly better:

~port ="/dev/ttyACM0");

I am stupid: I used a non existing baud rate (115000 and not the correct115200)

Last week I’ve used SerialPort on Linux with an arduino and I didn’t encounter any problems whatsoever.
Is your problem solved now with the correct baud rate?

Aha okay.

I think the main solution for me has been adding while (!Serial); to my setup function on my Teensy. This way it waits for a connection to be established before it sends data and it seems to help quite a bit for me at least. I am trying more complex usecases for serial in sc in the coming days so we’ll see how that goes.

Ah! I didn’t think of pasting my arduino code. I indeed have that same code in my setup function.