The Artima Developer Community
Sponsored Link

Java Answers Forum
ascii in java

1 reply on 1 page. Most recent reply: Mar 29, 2002 11:31 AM by Jay Kandy

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
sunsern

Posts: 3
Nickname: sun919
Registered: Mar, 2002

ascii in java Posted: Mar 28, 2002 10:22 PM
Reply to this message Reply
Advertisement
hi there,
I do have a question to ask you regarding the ascii. Basically i've written a java program that send a bunch of ascii text out to seiral port. The serial port is connecting to plc. I've try to send this from hyper terminal and it works fine. The problem is when i try to do the same thing but in java instead the program didn't work as expected. This is the list of command that i've sent from hyper terminal " alt-2(stx)100A00135alt-3(etx)CE " and plc output lit at y0,y2, y4,y5. I've try to do this exact command in java which is :
String mn = "02100A0013503CE" ;



output.write(mn.getBytes());

and this does not work ( the indicator on y0,y2,y4,y5 did not lit ) . I've also try to work around this using

String mn = "02 1 00A0 01 35 03 CE" ;

and String mn = "STX100A00135ETXCE" ;

and String mn = "STX 1 00A0 01 35 ETX CE" ; and none of it work at all. Do i needed to insert a special command which make sure that stx and etx is sending properly rather than sending s and then t and then x

please help

sincerely yours

sunsern


Jay Kandy

Posts: 77
Nickname: jay
Registered: Mar, 2002

Re: ascii in java Posted: Mar 29, 2002 11:31 AM
Reply to this message Reply
sunsern,

The string "alt-2(stx)100A00135alt-3(etx)CE" is confusing to me. Perhaps you could split the characters out:
alt-2
1
00
A ?? (or what is it?)

My best bet would be to try UNICODE values and send them as characters (not bytes).

This line:
System.out.println( "\u0002" );
or
System.out.println( "\u0002".toCharArray() );

prints alt-2 or IBM Character white face.

Good luck,
Jay

Flat View: This topic has 1 reply on 1 page
Topic: base class problem Previous Topic   Next Topic Topic: session.invalidate

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use