• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

write to serial port ?

 
Markus Schmidt
Greenhorn
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) Connector.open("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) Connector.open("comm:0;baudrate=9600;stopbits=1",Connector.READ_WRITE);
os = c.openOutputStream();
is = c.openInputStream();

is.read(bytearrayin);
os.write(bytearrayout);

is.close();
os.close();

} catch (Exception e){}
I placed the read,write and close commands in different orders...
Thank you for any help,
Markus
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic