473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to reconnect a serial port connection when connection is broken?

Good morning everybody.

First of all I would like to thanks for any answer or clue regarding this issue.

I am working with a gas detector application, and the customer wants I control all possible problems with the hardware.

For example, The gas detector application should be able to control if the hardware that send the signal is power off, or there is a problem with the cable.

I am using serial port communication. To start the communication, I have to send a package then the hardware start sending data. This process is in a loop. So, the result of these readings is a graph. The problem occurs when I disconnect the cable to read the hardware, The java application does not produce any exception. I mean it keep working with out any output. The gas detector app keep stuck in a sentences like this: outputStream.write(startReadingPackage). It does not send back any response.

I really appreciate if somebody gives me a help. I have to finish this part, it is rather urgent.

Thanks.
Feb 3 '11 #1
2 6131
horace1
1,510 Expert 1GB
if you are using a 'normal' COM port builtin to the motherboard or on a PCI card I would exepect no problem if the cable was disconnected - data reception should resume when it is reconnected.
On the other hand if you are using a something like a USB/RS232 converter, e.g.I use
http://www.ftdichip.com/Products/Cab...BTTLSerial.htm

when the USB is disconnected you loose the serial port and have to restart the Java serial port software.
In similar applications I send data regularly, e.g. every 10 seconds or 10 minutes depending on the application. You could have a timer in the Java application which if nothing is received within a set time you reinitialise the serial port and attempt reconnection.
In practice I gave up using serial ports for this tye of application sometime ago. I now use 10/100baseT ethernet, WiFi, Zigbee, MiWi, etc. Many modern microcontrollers either have facilities onchip or as peripherals connected via SPI or I2C.
Feb 3 '11 #2
horace1
1,510 Expert 1GB
thinking about this a bit more, could noise be generated when you disconnect the cable which is interpreted by the serial ports as a faulty character, e.g. an overrun error? the serial port then goes into a error state which you have to clear. What type of microcontroller do you have managing the gas detector? read up on the UART interface error conditions and the action required to clear them.
Feb 5 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
2
by: Mike C. | last post by:
I am trying to get Java v1.4.2 to use my PCI add-on serial port. So far, everything I try gives me javax.comm.NoSuchPortException at...
1
by: mimisam | last post by:
hi, I am using Win XP and writing an application to check POS devices (printer and cash drawer).In the application I need to choose the port which the device is connected to. If the port chosen...
4
by: dalewz | last post by:
Hi, Could sb kindly answer my following questions: Plan: I am trying to find a language to build a GUI to communicate with our device via serial port. Questions: 1. which language (VC++...
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
2
by: colin | last post by:
Hi, Im having a tiresome amount of trouble with using a bluetooth serial link. The receiving end is a bluetooth-rs232 module conected to my embeded system. The PC has a little usb bluetooth...
6
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send...
4
by: JDS | last post by:
I have an application that interfaces with a USB device using the .Net serial port. The code works fine, displaying live data on the screen; that is until the USB lead is pulled out from the PC...
3
by: cmdolcet69 | last post by:
Im trying to communicate to a DYMO Printer I set my serial port correctly however when I go into the device manager the DYMO isnt; listed in the Serial COM Ports? If I go into the printer console I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.