Hello everybody,

I am c# developer but I have c# application and want to change it with Java because sometimes I have problem. I have 7 modems and my clients send package to my application and I want to listen it with thread ans produce an answer to them. I use also mssql db to produce answer for clients. Please help me listen serial com port in Java. If you have a sample please share with me.

Have a nice day.

Darkocean, I can understood upto that client sends an package to your application. What was this sentence "I want to listen it with thread ans produce an answer to them" ? Why you use MSSql Db for produce answers? What necessery?
Please come with some more information. Then we can discuss on it...

Thanks Jayavardhan, I work with 7 modem which connect to com6,com7,com8,com9,com10,com11,com12 and I want to use thread because It must be process at same time. My clients connect to modem and sending a package and my application is getting this package and produce a answer to client and send it. I use mssql db because I am getting knowlegde on it but i can change it also I use http api for getting another information. First of all, modem gets "RING" and gets "CONNECT 1200/V.22b 2400/NONE" and gets the original package and I get it and process it.

Darkocean, Actaully listening serial ports in java was difficult. Because of Java's platform-independence, serial interfacing is difficult. Serial interfacing requires a standardized API with platform-specific implementations, which is difficult for Java.

Sun has defined a serial communication API, called JavaComm, but an implementation of the API is not part of the Java standard edition.
RxTx is available for a number of platforms, not only Linux. It can be used in conjunction with JavaComm (RxTx providing the hardware-specific drivers), or it can be used stand-alone. When used as a JavaComm driver the bridging between the JavaComm API and RxTx is done by JCL (JavaComm for Linux). JCL is part of the RxTx distribution.

I have to know which API you being used? If you may be used the above API's then you can try this below programming for listening the serial ports.

=Introduction and OSI Model=
{{:Serial Programming/Introduction and OSI Model}}
<br style="clear:both;" />
=RS-232 Connections=
{{:Serial Programming/RS-232 Connections}}
<br style="clear:both;" />
=8250 UART Programming=
{{:Serial Programming/8250 UART Programming}}
<br style="clear:both;" />
=Serial DOS=
{{:Serial Programming/DOS Programming}}
<br style="clear:both;" />
=Serial Linux=
{{:Serial Programming/Serial Linux}}
<br style="clear:both;" />
=Serial Java=
{{:Serial Programming/Serial Java}}
<br style="clear:both;" />
=Forming Data Packets=
{{:Serial Programming/Forming Data Packets}}
<br style="clear:both;" />
=Error Correction Methods=
<br style="clear:both;" />
{{:Serial Programming/Error Correction Methods}}
=Appendex A:Modems and AT Commands=
{{:Serial Programming/Modems and AT Commands}}


The above code was example for printable editing for serial programming. Incorporate or compare this code with you. May be it was useful for listening your serial port. Let me know if any issues.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.