fopen modes on a serial port with the STM32F4 BSP
Mr. Andrei Chichak
groups at chichak.ca
Wed Dec 10 06:08:24 UTC 2014
I was fighting with the STM32F4 BSP today, trying to get a serial port to talk and I had an odd experience.
Previously I used the MCF5282 family of BSPs and I used fopen(“/dev/tty01”,”w”); to open tty01 for write.
I tried this syntax on the STM32F4 BSP, fopen(“/dev/ttyS1”,”w”); and it bombed. perror told me that I had an invalid argument. Check, check, check, read, read, read, hack, hack, hack, I eventually figure out that if I use mode “rw” or “a”, the port will open and I can use fputs to send out stuff.
1) Could someone explain to me why “w” won’t succeed, but “rw” or “a” will?
2) On a similar vein, after enabling TTY1, 2, and 3 (instead of just TTY3) in configure.ac, the console port migrates down from TTY3 to TTY1. Apparently the first declared TTY will be picked up as the console. Is the recommended way of having 3 ports with TTY3 being the console, to reorder the ports in console-config.c, since BSP_CONSOLE_MINOR gets set to 0 in bsp.h (overriding my attempt at setting it in configure.ac)?
(I may need to work with someone to provide a patch to io.h, since TTY2 has three possible sets of tx and rx pins, not just two).
CBF Systems Inc.
4-038 NINT INNOVATION CENTRE
11421 SASKATCHEWAN DRIVE
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the users