Re: serial port question.



Chris.Reath@xxxxxxxxx wrote:
And I was successfully able to send and recieve an unsigned character
array of 255 chars. (from 00 to FF) However, I was only able to do so
by sending and receiving one byte at a time. I have been unable to
accurately send and receive more then 6 - 7 bytes at one time,

It sounds as if you haven't detected and dealt with short reads and short
writes. If your program does something like this:

ret = write(serial, "Hello World", 11);

You should look at the return value to see if all data was sent. If ret is
only 7 you have only sent the first 7 bytes and should then do a new call
with something like:

ret = write(serial, "orld", 4);

Of course the best thing for you is to write wrapper functions for read
and write that handles short reads and writes.

It was a long time since I wrote code for serial ports, but if I remember
right it was possible to avoid this behavior by turning off O_NONBLOCK
with an fcntl.

regards Henrik
--
The address in the header is only to prevent spam. My real address is:
hc8(at)uthyres.com Examples of addresses which go to spammers:
root@xxxxxxxxxxxxx root@localhost

.



Relevant Pages

  • Re: unexpected characters in TCP-communication
    ... that i say in the first byte of the string - i want to send - the ... number of chars, that i will send? ... When sending an array of bytes, ... When receiving, the return value from the Receive command indicates ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: UDP Sending an array possible?
    ... Is the receiving application a .NET application? ... -Yes...its actually 1 exe... ... it opens a UDP port and listens. ... I build the recieving parts to an array and do stuff with those arrays ...
    (microsoft.public.dotnet.languages.vb)
  • Re: "free space" with declared type
    ... >> But an array of char is an array of bytes. ... > effective type is also transmitted through memcpy). ... The declared type of 'ca' is array of four chars. ... The declared type of 'ip' is pointer to int. ...
    (comp.lang.c)
  • Re: UDP Sending an array possible?
    ... Is it possible to send an array instead of a straight line of text? ... i can make a huge string and send it and then ... Is the receiving application a .NET application? ... Sockets break data up into packets, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: sort() array names sequentially with numbers
    ... have numerals and I wanted to put them in sequential numerical order. ... returns the array in an order I do not want and is not consistent. ... What numCmp is doing is breaking the file names into arrays of digits and non-digit parts, then compares them - chars as chars and numbers as numbers. ... var x = a.replace; ...
    (comp.lang.javascript)