| 1234567891011121314151617 |
- What cfmakeraw actually does
- Behind the scenes, cfmakeraw performs the following bitwise operations on your termios struct to strip all formatting:
- Input modes (c_iflag): Disables flow control and character translations (e.g., IGNBRK, BRKINT, PARMRK, ISTRIP, INLCR, IGNCR, ICRNL, IXON).
- Output modes (c_oflag): Disables output processing (e.g., OPOST).
- Local modes (c_lflag): Disables echoing, line-based input (ICANON), and signals (ISIG).
- Control modes (c_cflag): Clears the character size mask and sets it strictly to 8 data bits per byte (CS8).
- Important Next Steps for Raw Mode
- When you use cfmakeraw, it strips out timeout configurations (like VMIN and VTIME), which you usually need to manage how your blocking/non-blocking reads operate. You should manually set these after calling cfmakeraw to prevent your program from freezing indefinitely or eating up CPU cycles.
- For more reference, check out the Linux Foundation cfmakeraw documentation or review standard FreeBSD Manual Pages.
- If you'd like, tell me:
- What type of device are you communicating with? (e.g., Arduino, GPS module, modem)
- Are you planning to use blocking or non-blocking reads?
- I can help refine this example to match your specific use case.
|