Skip to content

Instantly share code, notes, and snippets.

@michaeltandy
Last active January 2, 2016 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeltandy/8250371 to your computer and use it in GitHub Desktop.
Save michaeltandy/8250371 to your computer and use it in GitHub Desktop.
Send a break to a serial/rs232 device from the terminal using tcsendbrake termios. I use this on OS X to soft-reset my mbed LPC1768. To compile: gcc -o sendbreak sendbreak.c Don't have gcc installed? I think it comes with xcode.
#include <termios.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc,char** argv) {
if (argc<2) {
printf("Usage: One parameter, the device to send the "
"break to. Example: %s /dev/tty.usbmodem622 \n",argv[0]);
} else {
int tty_fd = open(argv[1], O_RDWR | O_NONBLOCK);
tcsendbreak(tty_fd, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment