So, I messed around with serial communication on my Mac today, specifically trying to bump up the baud rate to 921600. Let me tell you, it wasn’t as straightforward as I thought it’d be.
First off, I needed to talk to this serial-over-USB thingy. Usually, I’d just fire up the Arduino IDE’s Serial Monitor, but I heard that it might not be the best when dealing with non-standard baud rates. So I thought, why not try something different?
I remembered reading somewhere that the stty command is the way to go for this kind of stuff. I had used it before to check serial port settings, but never to actually change anything. I plugged in my device and figured out its name was something like /dev/*.
My first move was to see the current settings. I typed in stty -g -f /dev/* in the Terminal, and sure enough, it spit out a bunch of gibberish, but somewhere in there, it said the speed was 9600. That’s the default, and way too slow for what I needed.
Time to change things. I bravely entered stty -f /dev/* 921600 and hit Enter. No errors, that was good. I checked the settings again with stty -g -f /dev/*. And hey, the speed was updated! It was showing 921600 now, awesome!
Now, here’s where it got a bit tricky. I tried to actually use this new setting by using the cat command, like so: cat /dev/* in another terminal. But it seemed like every time I’d close that connection or stop the program that was using it, the baud rate would just reset back to 9600. Super frustrating!
I found some old forum posts talking about this very issue on macOS. Some folks were saying it’s just a macOS thing, something about drivers or how the OS handles serial ports. It seemed like it wasn’t just me, which was kind of a relief.
But I wasn’t going to give up. I had already changed it to 921600, why wouldn’t it stay that way? I tried all sorts of things, running the commands in different orders, trying different terminals, even restarting my computer. Nothing stuck.
So, what’s the takeaway here? Well, changing the baud rate with stty is easy, but making it stay that way on macOS seems to be a whole other story. I’m sure there’s a way to do it, maybe with some special driver or a different tool, but for now, I’m stuck with the settings resetting every time. If anyone’s got a magic solution, I’m all ears!
Anyway, it was a fun little experiment, even if it didn’t completely work out. Learned a bit more about how macOS handles serial communication, and that’s always a win in my book.