Send image (.jpg) file over serial port
We are trying to interface one of our devices with our machines by having the device send a file over the serial port. The code for the external device is written in C. However, we have not been able to successfully compile any of our code to do this. This is one of the code snippets we used to try to open the serial port and send data:
Source: Serial Programming Guide for POSIX Operating Systems - Michael R Sweet
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
* 'open_port()' - Open serial port 1.
* Returns the file descriptor on success or -1 on error.
int fd; /* File descriptor for the port */
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
* Could not open the port.
perror("open_port: Unable to open /dev/ttyS0 - ");
fcntl(fd, F_SETFL, 0);
However, when we try to compile this code, we get an error that O_NDELAY is an undeclared variable. We think it has something to do with termios.h, but we have not been able to fix this. We also tried using FileOutputStream.h (Source: fileoutputstream.c File Reference) but we got a file not found error. Can someone point us in the right direction here?