USING LINUX WITH EV3 DEVICES
60
MultiConnect
®
PCIe MTPCIE-EV3 Developer Guide
Test Program()
The following simple C program is useful to test the modem issuing an AT command. The program opens the
/dev/ttyUSB0 interface and calls the write() and the read() function to send an AT command and receive the
subsequent output.
#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 */
#define USB "/dev/ttyUSB0"
#define BUFSIZE 1000
#define BAUDRATE B115200
int open_port(char *port)
{
struct termios options;
int fd;
fd = open(port, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
printf("open_port: Unable to open the port - ");
}
else
{
printf ( "Port %s with file descriptor=%i",port, fd);
fcntl(fd, F_SETFL, FNDELAY);
tcgetattr( fd, &options );
cfsetispeed( &options, BAUDRATE );
cfsetospeed( &options, BAUDRATE );
options.c_cflag |= ( CLOCAL | CREAD);
options.c_cflag &= ~(CSIZE | PARENB | CSTOPB | CSIZE);
options.c_cflag |= CS8;
options.c_cflag &= ~CRTSCTS;
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
options.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL | INLCR |
IGNCR);
options.c_oflag &= ~OPOST;
if ( tcsetattr( fd, TCSANOW, &options ) == -1 )
printf ("Error with tcsetattr = %s\n", strerror ( errno )
);
else
printf ( "%s\n", "succeed" );
}
return (fd);
}
int main()
{
int serialFD = open_port(USB);
char buf[BUFSIZE];
Summary of Contents for MultiConnect MTPCIE-EV3
Page 1: ...MultiConnect PCIe MTPCIE EV3 Developer Guide ...
Page 15: ...DEVELOPER BOARD MultiConnect PCIe MTPCIE EV3 Developer Guide 15 ...
Page 17: ...ASSEMBLY DIAGRAM MultiConnect PCIe MTPCIE EV3 Developer Guide 17 Bottom ...
Page 20: ...DEVELOPER BOARD SCHEMATICS 20 MultiConnect PCIe MTPCIE EV3 Developer Guide ...
Page 21: ...DEVELOPER BOARD SCHEMATICS MultiConnect PCIe MTPCIE EV3 Developer Guide 21 ...
Page 22: ...DEVELOPER BOARD SCHEMATICS 22 MultiConnect PCIe MTPCIE EV3 Developer Guide ...
Page 23: ...DEVELOPER BOARD SCHEMATICS MultiConnect PCIe MTPCIE EV3 Developer Guide 23 ...
Page 24: ...DEVELOPER BOARD SCHEMATICS 24 MultiConnect PCIe MTPCIE EV3 Developer Guide ...
Page 25: ...DEVELOPER BOARD SCHEMATICS MultiConnect PCIe MTPCIE EV3 Developer Guide 25 ...
Page 26: ...DEVELOPER BOARD SCHEMATICS 26 MultiConnect PCIe MTPCIE EV3 Developer Guide ...
Page 27: ...DEVELOPER BOARD SCHEMATICS MultiConnect PCIe MTPCIE EV3 Developer Guide 27 ...