Hi all, i'm writing a vb6 application and i need to communicate via virtual serial port (USB). If i unplug the device the application (and VB6) freeze (!). Hatsune miku clock widget download xp. Gajaraju tamil songs download. Apr 27, 2016 - AddItem (('COM') & i) iData = iData + 1 cboComm. Const FILE_ATTRIBUTE_NORMAL = &H80 '*** Create a Fuction to check whether COM exists or not. The purpose of this article is to demonstrate how you can perform serial port communication in the VBA (Visual Basic Applications – script editor included in any typical Microsoft Excel distribution) but without using the MSComm control or any other third party add-on or ActiveX. Maybe if i handle a timeout on the tx, i should unblock the situation but i don't know how to handle the serial port timeout or turn the tx in a async call. -- SteM Are you reading the data in a loop? If so, you can either switch to event driven comm, or add a timer that will fire when you want the timeout to occur. In the timer event, disable the timer (only need it to fire once) and set a boolean that tells your code to jump out of the loop. ![]() Hi, In general, the port is closed by Windows when the device is unplugged (this is done by the driver that creates the Virtual Serial port). Thus, you should get an error if you attempt to send data on the closed port. If you do not get an error, I suspect that you need to check with your USB device manufacturer to see if there is an update to the driver. I normally DO NOT suggest that you open and close the port often. However, there are situations where this is necessary, and you may have encountered one. What I do is to create a Watchdog timer (use the Timer control), and call the timer routine fairly often. In the timer, On Error Resume Next With MSComm1 If.PortOpen = True Then.PortOpen = False.PortOpen = True If.PortOpen = False Then MsgBox 'Watchdog could not open port. Check hardware.' End If Else If YouKnowThePortShouldBeOpen Then.PortOpen = True If.PortOpen = False Then MsgBox 'Watchdog could not open port. Check hardware.' End If End If End With Dick. There are situations where this is necessary, and you may have encountered one. What I do is to create a Watchdog timer (use the Timer control), and call the timer routine fairly often. In the timer, On Error Resume Next With MSComm1 If.PortOpen = True Then.PortOpen = False.PortOpen = True If.PortOpen = False Then MsgBox 'Watchdog could not open port. Check hardware.' End If Else If YouKnowThePortShouldBeOpen Then.PortOpen = True If.PortOpen = False Then MsgBox 'Watchdog could not open port. Check hardware.' End If End If End With Dick -- Richard Grier, MVP Hard & Software Author of Visual Basic Programmer's Guide to Serial Communications, Fourth Edition, ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March 2006.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |