Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

write to serial port ?  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the wireless toolkit (sun) I can read the serial port using "...(StreamConnection)"comm:0;baudrate=4800",Connector.READ_WRITE)...".
I am not able to write to the serial port.

Here is the code snippet:
byte bytearrayin[] = new byte[300];
byte bytearrayout[] = new byte[3];
StreamConnection c = null;
InputStream is = null;
OutputStream os = null;

bytearrayout[0] = 125;
bytearrayout[1] = 0;
bytearrayout[2] = 38;

try {
c = (StreamConnection)"comm:0;baudrate=9600;stopbits=1",Connector.READ_WRITE);
os = c.openOutputStream();
is = c.openInputStream();;


} catch (Exception e){}
I placed the read,write and close commands in different orders...
Thank you for any help,
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!