jes notes Index Gallery . Shaft passers Snap issues

2024-02-14

Last modified: 2024-02-14 13:59:13

< 2024-02-13 2024-02-16 >

Go channels

I've worked out how the Grbl module should use channels!

I should not have a dedicated "writer" goroutine, or either of the dedicated "tickers". Instead I should just have one goroutine, and it uses select to read from the tickers, and to read from the channel that is telling it what commands to send, and to read from the output of the serial device (may need a second goroutine to turn serial reads into channel reads though). And it also uses select when it has a status update, in a loop, so that arbitrarily many readers can consume grbl status updates. The status update would be its own GrblStatus object or something, so that it doesn't change once it's come out of the channel.

This would solve most of the race conditions, but there's still the one where Grbl itself sends an update describing the size of the serial buffer, and then we send a command to it, and then we receive the update about the serial buffer and it looks like we've calculated it wrong. Not sure anything can be done about that though.

< 2024-02-13 2024-02-16 >