Skip to content

Instantly share code, notes, and snippets.

Last active January 2, 2016 04:28
What would you like to do?
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