This content has been marked as final. Show 3 replies
hello to all...Sorry, but RS232 hardware is capable only to transmite bytes (ok, there is possible to send 5,6,7 bits but most of other hardware devices won't understand that) and add parity to those bytes. The stop bit/start bit is essential for RS232 hardware and you cannot acces nor modify that. The extra stop bit is just a one bit long pause between bytes.
i am working on a project to make fast serial
But, i find a problem how to send data in packet and
add parity,stop bits to packet not to 8 bits....
If you need to design your own protocol think in terms of bytes: add header byte, add checksum (or better-CRC) byte and think about structure. The good example is XModem protocol.
When working with Java and RS232 always construct package in memory, in byte buffer and tell javax.comm to send it in single write() invocation. It will then make you sure that all bytes comes out just one-by-one, back-to-back with as small pause between them as possible.
Btw., serial transmission through RS232 won't be fast by nowadays means. It will run up to 115200 bits per second what gives you 11520 bytes per second. It is not much.
In my optinion Java+Sun's javax.comm is not fast enough to do trusted serial port communication on slow machines, esp. if short turn-around time is necessary.
As per your suggestion I am implemeting my Protocol Layer with Header,checksum & footer while sending & receiving data over Serial Port.
I am able to write data on Serial Port successfully but I am facing problems while reading data from the port.
From target I am receiving large chunk of data .As per the observation this chunk of data is available on serial port in data packets i.e. whole data is not available at the same time. I am using one Thread which is continously reading data available on the port.
As per the agreed frame structure from both Host i.e. PC & target, 1st byte will be header,2nd byte will be data length 2nd last byte will be Checksum & last byte will be footer.
So whenever large chunk of data is available in small packets I am checking data length if this data length is > available bytes on InputStream I am storing whole data in one temp buffer till data length. Till this point everything is working perfectly fine but I am not able to recevie the last byte i.e. footer. When I am executing my next test case then this last byte of previous data frame is available with response of next frame in the 1st position follwed by Header of next frame.
Can anybody tell me why this is happening..I have tried every possible way..:( No success.Pls somebody show me the path.