Serial Com
Mrlaser
Posts: 13
I am trying to establish a serial communication link between my Javelin and another instrument. For this, I would like to be able to receive and read a packet of 8 characters (or 8 bytes) all at once with the Javelin. How can I do that?
From what I know so far (I am relatively new to the Javelin, so excuse me if I have missed something), it seems that·I can only read what is received by the Uart only one byte at a time with Uart.receiveByte(). But it also seems to me that the Uart has an internal buffer. How can I acces this buffer, and read the content of this buffer all at once in one statement?
Thanks for your help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lasers will rule the World!
From what I know so far (I am relatively new to the Javelin, so excuse me if I have missed something), it seems that·I can only read what is received by the Uart only one byte at a time with Uart.receiveByte(). But it also seems to me that the Uart has an internal buffer. How can I acces this buffer, and read the content of this buffer all at once in one statement?
Thanks for your help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lasers will rule the World!
Comments
·
·/**
·· * Receive a String. This method blocks until num characters are received.
·· *
·· * @param data the character array to hold the string.
·· * @param num Maximum number of bytes to receive.
·· * @param offset Index in data to start from.
·· */
· public void receiveString(char[noparse]/noparse data, int num, int offset) {
··· for (int i=0; i<num; i++) data[noparse][[/noparse]offset++] = (char)receiveByte();
· }
or get my adapted Uart class, gives also direct access to the buffers.
Read that class to know what methods are available.
You need Uart.java and UartTools.java
rename your current Uart.java to Uart.org (in folder lib/stamp/core
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/core/
regards peter
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lasers will rule the World!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lasers will rule the World!