termios structure sanity check

Some initial testing with setting up serial communication flummoxed me. I decided to work up a tool to give me a hand.


Any evening you get to use the ternary operator is a good one, right? ssanity runs through all the macros in termios.h (almost all them… working on it) and checks to see if those flags are set in the termios structure. It’s not super complex – just a lot of this…

t->c_iflag & ICRNL ? printf("ICRNL: Set\n") : printf("ICRNL: Unset\n");

…over and over again. ICRNL is a flag that can be set, and that line will print out whether or not it is. I considered simply not having anything print out if it was unset, but I wanted to be more verbose.

So, now that I have a useful tool worked up I can likely make more effective attempts later this week! I’m having a good time. “Advanced Programming in the UNIX Environment” by Stevens and Rago is an absolute delight to read. I wish I had picked it up years ago. Its best feature is that it actually comes clean when something is complicated. It’s refreshing to know when something is supposed to be hard!

I’ve missed using Git in my day-to-day programming. It’s a wonderful way of focusing your attention to how your program is organized when more than one file is in play.

ssanity will need another pass for cleaning up and commenting, and I’m considering adding a few more things to check for the sake of completeness (despite the fact I won’t use them in my particular project). Ah – I need to remember to incorporate a makefile, too.

This entry was posted in Hobbies, Programming. Bookmark the permalink.

1 Response to termios structure sanity check

  1. Mom says:

    Most of that post is gibberish to me. I’ll stick to English and French. Programming is Greek to me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s