Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Hyperterminal and java communication to Serial port COM1

Thread view: 
lrantisi - 15 Feb 2007 04:03 GMT
I use the hyperterminal to communicate and send commands to serial
port COM1.
On the hyperterminal window, I used to type such a command:

AT+ZV SPPCONNECT.......

This command is sent to the device connected to the COM1 port.

Now I want to cancel the hyperterminal, and sue a Java program.
I used the javax.comm library to build a java application that
communicates with the COM1 port.

Inside that program, I connected to the COM1 port. How do I send that
text command from inside the java program to the COM1 port. There is a
method called (send) inside the (serialport) class, do I just say:

serialport.send "AT+ZV SPPCONNECT.......".

I mean, is sending text commands through the hyperterminal simply
equivalent to sending those text commands to the COM1 port using the
java application described above.

Now: Is sending the text command to the COM1
Thomas Fritsch - 15 Feb 2007 16:23 GMT
> I use the hyperterminal to communicate and send commands to serial
> port COM1.
[quoted text clipped - 3 lines]
>
> This command is sent to the device connected to the COM1 port.
It seems you are referring to the examples given at
<http://java.sun.com/products/javacomm/reference/docs/API_users_guide_3.html>,
don't you?

> Now I want to cancel the hyperterminal, and sue a Java program.
> I used the javax.comm library to build a java application that
[quoted text clipped - 5 lines]
>
> serialport.send "AT+ZV SPPCONNECT.......".
This is not even syntactically correct (hence I assume you are still a
very beginner in Java). It will be probably more like
  OutputStream outputStream = serialPort.getOutputStream();
  outputStream.write("AT+ZV SPPCONNECT.......".getBytes());
  outputStream.flush();

> I mean, is sending text commands through the hyperterminal simply
> equivalent to sending those text commands to the COM1 port using the
> java application described above.
I suppose so (although I have no practical experience with javax.comm).
But using javax.comm is not only about sending bytes. It is also about
waiting for responses (and that is probably the more difficult part).

> Now: Is sending the text command to the COM1

Be warned: Before you will have any chance for mastering the javax.comm
package, there is much work for you to prepare the basics:
(1) Learn the Java language (the syntax and concepts)
(2) Learn the basic Java classes (like OutputStream)
(3) Read the API docs at
    http://java.sun.com/products/javacomm/reference/api/index.html

Signature

Thomas



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.