I'm trying to get my Java flight data acquisition program, which runs on a single-board computer with Lubuntu 16.04, to talk to the Betaflight Nero F7 IMU sensor board, which is connected to the SBC through a USB port. It works fine on the laptop I use for development (running Ubuntu 16.04), but on an SBC it won't respond after rebooting.

I thought it might have something to do with the default baud rate, which is 115200 on the laptop and 9600 on SBCs. If I change it on the SBC using the screen command, then my code can talk to the sensor:

screen /dev/ttyACM0 115200

If (after a reboot) I change it using the stty command, I still can't talk to it:

stty -F /dev/ttyACM0 115200

In both cases, the baud rate appears to be set correctly:

setserial /dev/ttyACM0 -av

/dev/ttyACM0, Line 0, UART: unknown, Port: 0x0000, IRQ: 0
    Baud_base: 115200, close_delay: 12, divisor: 0
    closing_wait: none
    Flags: spd_normal low_latency

When I use the Betaflight configurator utility (a Chrome app), it can open the device and talk to it. After that, my code also works. Their default baud rate is 115200, but if I change it to e.g. 9600, it still works.

I also ran the stty command to get additional port settings and tried making them exactly the same as they are after the configurator utility opens the sensor:

stty -F /dev/ttyACM0 -a

speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint ignpar parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo -echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

But even when the settings match exactly, my code still won't work on the SBC until I run screen or their configurator. I can rule out the different state of the sensor because it works right away on the laptop. What other magical setting can screen and the config utility change that I can't catch with setserial and stty?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.