CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007
    Posts
    24

    Application looses communication after 1 or 2 days

    Hi,

    I have an multi threaded application developed using C under Microsoft Visual Studio.
    The application runs on desktop computer and the devices are connected to the computer USB port using a USB toRS485 converter. All devices communicate to the computer on RS 485 bus.

    It has the following threads.

    Main application thread

    RxThread communicates with a Labview application on TCP/IP

    protocol_RxThread and

    protocol_TxThread are used for communicating with the devices.

    The system works well for 1 or two days and it stops communicating after that. I have observed that the computer gives an error message saying that the device connected to the USB port is not identified. Now I need to findout whether it is
    1. Problem with the USB port - Is it freezing after some days of working.
    2. Problem with the converter I am using.
    3.Problem with the threads used for communication.

    When the application looses communication, I have seen that the application communicates with the Labview application on TCP/IP which is running on the same computer. When I check the COM ports on Device Manager, the USB device is not shown and after some time it comes up with an error saying that there are no drivers for the attached USB device. If I disconnect and reconnect the USB device it finds the device and still the application did not communicate with the devices. But when I quit the application, it quits without any problem.If I do not reconnect the USB device and try to quit the application it does not quit,It disappears from the application but stills runs in the processes in the task manger window. To quit I need to kill the process.

    I am struggling with this problem from last six months, earlier I was assuming that it could be problem with the threads, but with recent observations I am thinking it could be problem with USB port or the USB to 485 converter.

    If any one can suggest a solution for this I will be verymuch greatful.

    Thanks

  2. #2
    Join Date
    Nov 2006
    Posts
    1,611

    Re: Application looses communication after 1 or 2 days

    The fact that the USB device is no longer recognized by the OS is suggestive of a USB driver/hardware/OS related problem.

    The shutdown problem sounds like a problem with error conditions during shutdown within the application - not really a serious application problem, just an oversight with respect to how to handle the situation where the USB device disappears while the application is under the assumption that the device is still there. That can be tested independently (perhaps by deliberately removing the USB device after startup and observing/researching the point where the application hangs).

    Without further context and/or code, it's hard to be of more help. You could try running this on a different computer to see how it responds, but the timeframe to failure is certainly an obstacle.
    If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).

  3. #3
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Application looses communication after 1 or 2 days

    it seems to me too that the fundamental problem is with the device / driver itself and not your application. However, some of the problems associated with your application not behaving right could be streamlined, I guess.
    You might want to explore WM_DEVICECHANGE. When you do get into the situation where the device doesn't show up anymore in device manager after continous usage, please check to see if you are receiving a WM_DEVICECHANGE. If you do get it and after confirming it is due to your device being unplugged by the system, what you need to do is to abort all communication with the device. That should revert your application to such a state as if it has not detected device. Also, in the no device detected state, you should also start listening to WM_DEVICECHANGE again. This is one message you should listen to with plug and play devices. You will be notified with DBT_DEVICEARRIVAL and DBT_DEVICEREMOVED or something of that sort and take actions appropriately.

  4. #4
    Join Date
    Oct 2007
    Posts
    24

    Re: Application looses communication after 1 or 2 days

    Hi Thank you for your answers. I will try your suggestions and will post my observations.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured