Re: Problem to read on a serial port
by collinm » Fri, 01 Apr 2005 03:13:37 GMT
ok changed that, now in my function i do a write and a read...
void writereadopen(char msg[], int size)
{
int fd1;
int wr;
int rd;
fd1 = open(ledisplay, O_RDWR | O_NOCTTY | O_NDELAY );
if (fd1 == -1)
fprintf(stderr, " %s open_port: Unable to open %s\n",
strerror(errno), ledisplay);
else
{
fcntl(fd1, F_SETFL, 0);
wr=write(fd1, msg, size);
if (wr < 0)
fputs("write() of n bytes failed!\n", stderr);
else{
char buff[20];
printf("write\n");
rd=read(fd1, buff, 20);
printf(" Bytes recieved are %d \n",rd);
}
}
close(fd1);
}
i see the write message... but that seem to wait
all code i checked on the web have that, i'm a newbie with seria
programming
i remove fcntl(fd1, F_SETFL, 0);
and i put
fcntl( fd1, F_SETFL, ( fcntl( fd1, F_GETFL ) & ~ O_NONBLOCK ) );
i see the write message... but that seem to wait
i write on serial port without problem... i only have problem when i
read
communication
serial
settings
that.
lot
manage
i'm able to write on the serial port... i send some command to
initialize the led display, another to send message...
i need to read on the led display because we want to know if what we
send to the led display is ok....
our solution is to send a command and after we read this command...
at
waht i need to change to use another mode?
end,
binary
in
send
make
buffer
but
Manual
numbers
i need to send a special command to the led display if i want to read
something about it
with: char msg[]={'\0', '\0', '\0', '\0', '\0', '\1', 'Z', '0', '0',
'\2', 'F', '&', '\4' };
with this string, i ask to led display to send me the day of the week
...
the led display is suppose to send me something like
\0 \0 \0 \0 \0 \1 0 \3 \3 \2 E & 6 \03 00A6 \4
\0 = null
\1 = start of header character
0 = response code
\3 = sign of the actual address
\2 = start of text character
E = is the read special function
& = read day of week
6 = stands for friay
\03 = end of text character
00A6 = checksum
\4 end of transmission character
common
very
ya, we use time since week without problem... we have a bash file who
write every x time to the led display (who use this cable)
no problem :) , you are the expert