For now I can get data from my webpage. So if I want to send the data to serial port on mini2440 OS linux. Questions 1.Where should I start from? 2.On linux-example how can I run it from mini2440? Thank you.
How can I connect serial port with CGI?
You should need to know about serial programming: http://www.faqs.org/docs/Linux-HOWTO/Serial-Programming-HOWTO.html Just write a C program (CGI) to read and write data. Here is example: #include <stdio.h> #include <string.h> #include <fcntl.h> /* File control definitions */ #include <termios.h> /* POSIX terminal control definitions */ #include <sys/ioctl.h> int open_port(char * serial_name); /* * 'open_port()' - Open serial port 1. * * Returns the file descriptor on success or -1 on error. * */ int open_port(char * serial_name) { int fd; /* File descriptor for the port */ fd = open(serial_name, O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { /* Could not open the port */ printf("open - ERROR \n"); } return (fd); } int main(int argc,char* argv[]) { int ret; int mainfd=0; /* Serial file descriptor */ int nread, n_received; struct termios options; mainfd = open_port("/dev/ttySAC0");// com port 1 if(mainfd < 0) return -1; /* Configure port reading */ fcntl(mainfd, F_SETFL, FNDELAY); /* Get the current options for the port */ tcgetattr(mainfd, &options); cfsetispeed(&options, B9600); // Set input the baud rates to 9600 cfsetospeed(&options, B9600); // Set output the baud rates to 9600 options.c_cflag |= (CLOCAL | CREAD); // Enable the receiver and set local mode options.c_cflag &= ~PARENB; // Mask the character size to 8 bits, no parity options.c_cflag &= ~CSTOPB; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; // Select 8 data bits options.c_cflag &= ~CRTSCTS; // Disable hardware flow control options.c_lflag &= ~(ICANON | ECHO | ISIG); // Enable data to be processed as raw input /* Set the new options for the port */ tcsetattr(mainfd, TCSANOW, &options); //write(mainfd, "test_", 8); // test /* Close the serial port */ close(mainfd); return 0; }