First I am learning this as I go so please forgive my ignorance, all is self taught. I was given this as program to run an LED signboard for my fire station. The program is supposed to transmit the calls to the signboard so we can see what piece is due to go out the door. The problem is I am getting several warnings and also the program is sending multi-colors instead of just one. Any help is greatly appreciated.
betabrite.c In function main :
betabrite.c:88: warning: comparison between pointer and integer
betabrite.c:88: warning: comparison between pointer and integer
betabrite.c:93: warning: comparison between pointer and integer
betabrite.c:94: warning: passing arg 2 of 'write' makes pointer from integer without a cast
betabrite.c:96: warning: passing arg 2 of 'write' makes pointer from integer without a cast
betabrite.c:98: warning: comparison between pointer and integer
betabrite.c:100 : warning: comparison between pointer and integer
betabrite.c In function main :
betabrite.c:88: warning: comparison between pointer and integer
betabrite.c:88: warning: comparison between pointer and integer
betabrite.c:93: warning: comparison between pointer and integer
betabrite.c:94: warning: passing arg 2 of 'write' makes pointer from integer without a cast
betabrite.c:96: warning: passing arg 2 of 'write' makes pointer from integer without a cast
betabrite.c:98: warning: comparison between pointer and integer
betabrite.c:100 : warning: comparison between pointer and integer
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "betabrite.h"
#define DEFAULT_SERIAL_PORT "/dev/com1" /* Cygwin */
int OpenPort(char *serial_port) {
int fd ;
fd = open(serial_port, O_RDWR|O_NOCTTY|O_NDELAY) ;
if (fd == -1) {
perror("OpenPort: Unable to open port - ") ;
} else {
fcntl(fd,F_SETFL,0) ;
} /* if */
return(fd) ;
} /* OpenPort() */
/* SetupSerial() - open the serial port and setup comm parameters */
int SetupSerial(char *serial_port) {
struct termios options ;
int fd = OpenPort(serial_port) ;
tcgetattr(fd,&options) ;
/* 9600 baud */
cfsetispeed(&options,B9600) ;
cfsetospeed(&options,B9600) ;
options.c_cflag |= (CLOCAL|CREAD) ;
tcsetattr(fd,TCSANOW,&options) ;
/* 7 bits */
options.c_cflag &= ~CSIZE ;
options.c_cflag |= CS7 ;
/* even parity */
options.c_cflag |= PARENB ;
options.c_cflag &= ~PARODD ;
options.c_cflag &= ~CSTOPB ;
options.c_cflag &= ~CSIZE ;
options.c_cflag |= CS7 ;
/* software flow */
options.c_iflag |= (IXON | IXOFF | IXANY) ;
options.c_oflag &= ~OPOST;
options.c_oflag &= ~ONLCR;
options.c_oflag &= ~OCRNL;
tcsetattr(fd,TCSANOW,&options);
return(fd) ;
} /* SetupSerial() */
int main(int argc, char **argv) {
int fd;
int n;
char *serial_port = DEFAULT_SERIAL_PORT;
fd = SetupSerial(serial_port) ;
n = write(fd,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",20) ;
n = write(fd,"\001Z00\002",5);
if(argv[1] == 'a' && argv[2] == 'a')
n = write(fd,"A0",2);
else {
n = write(fd,"A0\x1B ",3);
if(argv[2] == 'f')
n = write(fd,'c',1);
else
n = write(fd,'a',1);
if(argv[1] == 'g')
n = write(fd,"\x1C\x32",2);
else if(argv[1] == 'r')
n = write(fd,"\x1C\x31",2);
else
n = write(fd,"\x1C\x38",2);
n = write(fd,argv[3],strlen(argv[3]));
}
//n = write(fd,"AA\x1B b",5);
//n = write(fd,"\x1C\x32\x13",3);
n = write(fd,"\004",1);
close(fd);
return(0);
}
Comment