laamaa / m8c

Cross-platform M8 tracker headless client
Other
380 stars 81 forks source link

fix parameter list page crash #79

Closed yatli closed 2 years ago

yatli commented 2 years ago

✅ Linux: Tested ❓ macOS: Should work 🚧 win32: Does it have <unistd.h> at all? Should work for mingw64.

smootalicious commented 2 years ago

See my PR last few commits for a different approach to fixing this issue. I do like this approach, though. I guess if the port is open then the M8 is just unresponsive, and m8c won't disconnect. It won't compile in windows though due to - replacing those functions seems to be a bit of an issue though there is a rather large drop in replacement somewhere on github. There may be another way to check that the port is accessible via detect_m8_serial_device in serial.c perhaps?

bloopclick commented 2 years ago

I don't think that's the right way. If the USB port becomes disconnected, the serial port will become invalid and regular serial read/write calls fail. I'm not sure why anything special is needed to detect that.

yatli commented 2 years ago

@smootalicious yeah. Even if we have a drop-in replacement for unistd, there will not be /dev/ttyACM0. COMs in windows are handled another way, and it's better to use a generic detection routine.

@bloopclick I don't know. Guess the 0-byte detection is a way to work around some M8 quirks? Also, if I power off Teensy, it does spmetimes fall into that 0byte codepath instead of throwing an error.

smootalicious commented 2 years ago

Yes, it appears that the purpose of the zero-byte path is to automatically shut down m8c when the teensy is disconnected. The slight problem is that the M8 sends zero bytes on the help screens and it tricks the zero byte path into shutting down m8c. My crude solution was to reset the zero-byte counter if the user has a button pressed, since the help screens require holding down a button.

laamaa commented 2 years ago

@smootalicious yes, that's exactly why I used the zero-byte path - just didn't test it enough it seems :) I wonder if it would be possible to check for the device somehow via libserialport. It would be easy to call the M8 detection routine every now and then, but that probably doesn't play well with multiple devices.

laamaa commented 2 years ago

Fixed using packet write tests in #82