hi
under linux, i try to write to serial port who pluged to a monitor (del monitor)
with bash i do
Code:
echo -e \\000\\000\\000\\000\000\\001Z00\\002AA Keg Marty is in the house\\004 >/dev/ttyS2
that work fine.. Keg Marty is in the house is displayed on the panel
i would like to do the same thing in C
my c program (compile well... but don't work)
Code:
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main (void)
{
int iOut = 0;
int fd = 0;
char *sCompPort="/dev/ttyS2";
//char cmd[70];
char cmd[]="\\000\\000\\000\\000\000\\001Z00\\002AA Keg Marty is in the house\\004";
fd = open(sCompPort, O_RDWR | O_NOCTTY);
if (fd >0){
printf("port open");
iOut = write(fd, cmd, strlen(cmd));
close(fd);
}
else{
printf("not able to open port.");
}
if (iOut > 0){
printf("no commmunication.");
}
else{
printf("good Communication");
}
return (0);
}
return me port open and no communication...
any idea?