Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To 'disconnect' And 'reconnect' An USB Device Using A VB Program ??


Hi,

I am using a USB to Serial converter. The converter works OK for most of the time, but sometimes the converter stops working, the COM port assigned to it is removed from the registery by the Windows OS.

To re-establish the connection the converter needs to be un plugged and then re-plugged.

The OS now detects the converter and assigns the COM port.

Is it possible to unplug and re plug the device using a VB program ??
How do I make the OS start the detection process ??

thanks
arunb




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Disconnect - Reconnect
Why is it always that when i disconnect and try to reconnect to my client / server app, it doenst connect anymore. The first time i have no problems but when i press disconnect on the client side en press on connect again it doenst connect anymore, how do i fix this problem.

Disconnect In EVB Program
My codes to connect to an IP address is

wskMain.Connect

however, the codes to disconnect is wskMain.Close


anything wrong with that anyway??? but it did not disconnect my eVB program from the server.





Programmers are the laziest people around.

(VB6)How To Program For FingerPrint Device With VB6
Hi All,

Sorry if i make a mistake to place this question in this place.
But as I dont know where this question fits to i placed it here...

As my title says I want to create a program reading finger prints from a USB FingerPrint Device and save it as JPEG file?

Please I dont want to make use of any third party controls or like ...
Help me out of this problem.
How can I do this ?

Thanks..
amolt.

Program Autostart Upon USB Device Plugged In
I am a firmware engineer trying to expand my horizons. I have a device that connects via USB. I have written the GUI in VB6. Thats the extent of my VB6 experience. I need to delve a little deeper :-)

I am wanting my program to start automatically when said device is plugged in. This device uses and FDTI RS232<>USB chip, so the PC has a virtual COMM port driver from FTDI.

When the device is plugged in, the COMM port gets assigned, so I know there should be a hook somewhere. Each device gets it own COMM #, so I would need to know which COMM port to open automatically (I assume I can get that info from the hook?).

I tried searching, but I don't know the best keywords to use, so all were fruitless. If anyone could give me the best keywords, or point me to a FAQ, I'd appreciate it. I know there is one out there somewhere, as programs autostart all the time!! Thanks in advance.

Interfacing VB Program To Vernier LabPro Device
Hi All,

I have a program that is supposed to take some sensor values from this LabPro device I have. it is connected to the computer via the USB port but I have found some examples of how to program it in Visual Basic using the serial port. Since my computer does not have a serial port, is there any way that I can use a USB to serial converter and use the MsComm control to communicate with the device? I heard that it is possible to program it directly wit the USB port but it is much more difficult.

Thanks,
Jason O

Sending Command Program To PIC16F84 Device
hi.can anyone help me.i'm designing a pic programmer software using VB 6.0.i've loaded the HEX file.The problem is i can't program the file to the PIC.the code to program the PIC that is use is:
.
.
MScomm1.Output="P"
Sleep (100)
MSComm1.Output="P"
Sleep (100)

is the command right?

could anyone please link me to somewhere that i can refer to?thanks a lot everybody....

Error Playing EVB Program In Default Device
Hi, when I want to play my program in the Pocket PC, I encountered this problem.

Copy Failed(Error Code= 0xLX)
The file Windowspvbdecl.dll is locked by another process and cannot be copied.

Can someone please help?



Programmers are the laziest people around.

MP3 Player Program - To Copy Files To Portable Device
I own a portable MP3 player (to be specific a Philips Rush SA126) that connects to my computer via a USB cable and stores MP3 files on Smartmedia cards.

I'd like to make my own program to let me copy MP3 files from my hard drive to my MP3 player quickly and simply, it doesn't have to be fancy - it doesn't have to rip MP3 files from audio CDs, play or edit them in any way, just a simple interface to select the files and click 'Transfer' to put them onto my MP3 player.

If anyone has made anything like this, can i take a look at the source code?
If anyone has any idea how this can be done, please let me know. I basically need to know how to communicate with external devices using VB, and how to send files down a USB connection

Serial Mouse As Program Specific Input Device
i'm interested in a way to grab data directly from a serial mouse. I want to use the mouse to control a couple variable in my program, but i don't want it to move the mouse cursor.

basically, my system will have two mice. one is a USB Optical mouse and the other is a more traditional serial mouse.

Mouse A is the optical mouse
Mouse B is the serial mouse

I'd like to use mouse A to control the cursor on the screen and mouse B to control a part of my program. (Mouse B will be physically modified and will not resemble a mouse when I'm done, but will use the same interface)

How might I get the stream of data coming from Mouse B (the serial mouse)? Will I have to write my own driver or is there a way to connect directly to the serial port?

Reconnect?
I have a program in client side use winsock to make connection
with a streaming server. However, somtimes it will disconnect.
So, is there any method to check that if the connection is
close and reconnect to server immediately? Thanks!

Reconnect, Reconnect, Reconnect
Would anyone know how to avoid getting the below terminating error without having to keep reconnecting to Oracle? The subroutine where this is occurring I have two connections, one to an Oracle database, and one to an Access database. The goal of the subroutine is to transfer all of my Access records unto a table in Oracle. Aslong as I keep reconnecting, I'm fine. What kind of memory issues am I running into that forces me to keep reconnecting?

Error I'm getting:
The instruction at "0x1f....." referenced memory at "0x04.....". The memory could not be "written".

This is my reconnecting subroutine:

Public Sub ConnectToOracle()

If Conn2.State = adStateOpen Then
Conn2.Close
Set Conn2 = Nothing
End If
rs2.CursorLocation = adUseServer
Conn2.ConnectionTimeout = 3600
Conn2.Open "Driver={Microsoft ODBC for Oracle};Server=USTRQD51;Uid=mi_load;Pwd=info$load#;" ' QA database
Set Cmd2.ActiveConnection = Conn2
Cmd2.CommandTimeout = 1800
End Sub

Thanks!

Reconnect
Hi Pros., I have a application that connect to a SQL Server for retrieve the new data in every 5 minutes. But sometimes the SQL Server is disconnected. If I want to make my application retry the connection while the connection is downed and make it resume when the connection is back again, what should I do? Many thanks.


SQL Server Reconnect
I'm currently creating a VB application which requires connection to an SQL server database. I need a code which will keep my application running (keep updating, inserting, etc.) in case the server is down. It's sort of like a temporary buffer thingy which will in turn push the records entered once the server is running again. Can anyone please help...

Reconnect On Winsock...
guys,

 i'm developing a chat program. i'm currently using an array of sockets on my server.. testing was ok,, but problem emerged when somebody accidentally shut down the pc. the problem is that he cannot reconnect to the server and an error message appeared... the point is, i needed a mechanism to automatically reconnect to each other regardless of which session (client or server) was experiencing the network problem, and to do so without user intervention.

guys, i need your help... please..

Getting Device List From Device Manager With Setupapi
I had need to figure out which COM port a USB-serial converter was installed as. If you looked under Device Manager, it was easy to tell from the names. First I tried EnumPorts, but that just gave me the COM number and 'Local Port'. I tried using the WMI, but the device I was looking for was the one that it wouldn't list for some reason. (Worked fine for my other virtual COM port USB device.) So I stumbled onto the setupapi library, but there was no VB examples, only some C. So through some trial and error, I devised a DeviceLister VB6 class to get names and descriptions of devices. It could be changed to include more, but I stopped at names/descriptions.

By five-cent example returns a list of 'Ports' devices (your results will vary):
ECP Printer Port (LPT1)
Communications Port (COM1)
Digi PKG-U Serial Port Adapter (COM16)
^-that last one was the sucker I was after

I thought 'Hey I wonder if anyone else would be looking for this?' so I post it here. It's not the prettiest implementation, but might be a starting point for someone.

Note: The MSDN seems to indicate that this only works for Win2k and beyond.

EDIT: I added an example of retrieving all devices. Also I setup an option to list devices that are not present. Now I can see ports that were installed but aren't active.




Edited by - FD 80 on 6/20/2008 11:35:57 AM

Reconnect Attempt Loop
I'm using winsock and a timer loop to try to reconnect every x ms. On my computer reconnecting every 80ms uses very little bandwidth, however on other computers it is such a bandwidth hog that it can simulate a DoS attack on the computer it's running and effectively cause their internet connection to drop. Does anyone know why this phenomena happens?

Winsock Reconnect Error
I have another problem with winsock.

After i close the connection (Winsock1.close on both sides, server and client application) with the other application, and try to connect again i get an error. But if i close both applications, reopen them and try to connect again everything works fine.

Winsock Reconnect Question
If I have a winsock control on a client that has sent data to a server but for some unknown reason the winsock has closed before receiving a response or all of the expected data back from the server how can I reconnect the winsock and resend the data?
When winsock.close occurs there is a timer enabled and that timer starts to parse apart the data received so far. It checks for the end of string (</p3Gram, if this is not there it throws the error I am seeing - incomplete message.

Here is code from the timer1

Code:
Private Sub Timer1_Timer()
Dim MyPos As Long, MyPos2 As Long
Dim getData As String, strData As String

Timer1.Enabled = False

If Len(globstrData) < 1 Then
globstrData = ConCat.GenerateCurrentString
End If

'If Len(globstrData) < 1 Then
' globstrData = datastr
MyPos = InStr(globstrData, "</P3GRAM")
If MyPos > 0 Then
globstrData = Left(globstrData, MyPos - 1)
End If
'End If

MyPos = InStr(DataStr, "</P3GRAM")
MyPos2 = InStr(MyPos + 1, DataStr, ">")
If MyPos2 < MyPos Then
m_ResponseCode = 86
m_ResponseInfo = msgClient_086 + " EID=993"
TextResponseCode.Text = Str(m_ResponseCode)
TextResponseInfo.Text = m_ResponseInfo
Call CauseCompletion
Exit Sub
End If
End Sub

And the winsock close event

Code:
Private Sub Winsock32_Close()

If i_Mode <> 1 Then
Winsock32.Close
End If
Timer1.Enabled = True

End Sub


What I would like to do is just start over with reconnecting the winsock and send the original request back to the server with an additional string. The odd thing I have seen is if the original request (usually a sql statement) is a certain length it fails. If I send the same sql statement with another statement appended on the end then it works. It seems to me the winsock control is dividing things up incorrectly or is losing them. Losing packets I though was not possible with TCP, which this winsock is using.

Thanks for anyone who looked at this long post, but this problem has been bugging me for a long time and I would like to get it resolved. Talked to Microsoft and all they could tell me was to recompile with service pack 6, and check for the connection is active before calling senddata. But it looks like to me that the connection is cut off in the middle.

Thanks,
mojo

Auto Reconnect Onto Internet
I was just wondering how I would go about coding a program that reconnects automatically onto the internet on the same account I was using, as soon as I get disconnected.

I have a dailup 56kmodem, get disconnected every 2hrs, so that's why

Automatically Reconnect After Error
In an Access project connected with a SQL Server database, users must reconnect using File/Connection after the connection is broken when a network error occured.

How can I do this automatically, using VBA and the settings on the Data Link Properties dialog box ?

UDP Client Reconnect Problem
I have scoured the net for solutions to this before posting here but there isn't much help out there. I am writing a UDP Client program to talk to a UDP Server (written in VB 6 using Winsock). The problem is that I can communicate with the server fine and do many send and receives to and from it. The problem is that when I close my app and re-run it, the first time I send a datagram to the server, it appears that the program not only sends the string that is programmed, but also a single 1 byte empty string. The Server responds to the first correct line but the packet is never received by my client. Therefore the client hangs as the receive line stops the program as it waits for the response. The onlyt way to get the program to work again I have to restart the server program.

I am assuming the client is causing the problem as I can't see how/why it sends this blank string. I am thinking its becuase for whatever reason, the second time the program runs the socket is dead or already connected. I do however close the socket and set the object to nothing...

Does anyone have any ideas? Thanks

Winsock Help - When Server Reboots/lan Down How To Reconnect
Hi - right now my project starts up with the PC and sends data, but then might not need to send data until the end of the day, but it is possible it will send data quite often throughout the day...

So right now the connection is made at program startup and used when needed, which is fine - however, if the server is rebooted, or if the lan goes down for a second or something, the client/server loose their connection - so what is the best way to have the winsock control:

either:
1. Determine that the connection is down and re-establish it
2. Only make the connection when needed???? (tried it this way and having trouble)

Any other ideas?

Thanks guys

Chris

Force Netword Drive To Reconnect
Hi

I have a mapped network drive that can only reconnect after windows has loaded a special VPN program during startup therefore when windows loads it isn't possible for it to reconnect the network drive. Is is possible to using code to force windows to try to reconnect the drive again after startup has completed.


Your help will be appreciated.

Closing A Winsock Connection So You Can Reconnect
How can i make a winsock connection close so that i can reconnect? Thanks

Winsock Reconnect But Doesn't Connect
hello again I am working on a little winsock project to help me learn.
I have come across a problem when I select an option then stop it I want it to then close the winsock connection and reconnect but it just says connecting I'm sure this is a simple problem, here is the code I use to close connection and reconnect.

Code: winsock.Close
winsock.Connect Server.Text, 10

but it just says connecting If I click the disconect then reconnect button it connects fine and I use the exact same code to disconnect and reconnect

Code:Private Sub Connect_Click()
winsock.Close
winsock.Connect Server.Text, 10
End Sub

Private Sub Disconnect_Click()
status.Caption = "Exited"
winsock.Close
End Sub

thanks.

Auto Reconnect To DB After SQL Server Restarted
Dear All,

I'm coding an application to check for specific record on a table in every 15 seconds.

How can I:
1. check for server/db disconnection (e.g. SQL Server restarted or network disconnected) and
2. auto reconnect to DB

I've seen many error handling codes on the internet, but that's not enough for my case.

My platform:
OS: Windows 2000 Server SP4
DBMS: SQL Server 2000 SP3a
Tool: VB6 SP5 & ADO

Super Thanks.

Fergus



Edited by - ferguscham on 11/19/2003 12:19:51 AM

Reconnect MSComm (Alternatively Known As The Control Spawned In **** )
Everyone or even just anyone!

I am new to using the MSComm control (either that or I just suck at coding) and I am having a problem with it.

In my application, during load up, I connect my MSComm and get a connection fine. At present I am trying to make the application a little more rhobust by checking for a return within a certain amount of time, if no return is received I then try to disconnect and reconnect my MSComm control using the PortOpen property. This is where the problem is, I just can't seem to get the MSComm control to reset it's connection. Does anyone have any clues as to why this would be, even if you could just point me in the right direction I would be really grateful

Thanks anyway.

Christopher

Uninstall A Device From Device Manager.
Hi all,
Is there a way to uninstall a device in device manager with vb6?

I've run into a rootkit that I am trying to make a tool of mine remove. I've tried simply stopping the service but this can cause BSOD's which we all know are fun in windows.


As always any help is appreciated,

Dave

Using Winsock Control...after Connecting To The Client And Disconect I Cant Reconnect
using the host program i connect to the client program

but after disconnecting from the client program
i cant reconnect to it

i have tested the host program so i know it isnt it
what could be wrong?
heres the client code:
-----------------------------------------------------------
Private Sub Form_Load()
Winsock1.Listen
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strIncoming As String
Winsock1.GetData strIncoming
txtMessageBoard.Text = txtMessageBoard.Text & strIncoming & vbCrLf
End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock1.Close
End Sub

Why Does It Disconnect?
Hi, I have a client and a server for a game I'm making. They both send each other data until eventually the client calls DX and loads it on the screen. Then when you hit escape, it calls this sub:


Code:
Sub EndMe()
'Restore the screen resolution.
Call dd.RestoreDisplayMode
Call dd.SetCooperativeLevel(frmGame.hWnd, DDSCL_NORMAL)
'Stop the program:
frmGame.Winsock.SendData "logd¿"
bRunning = False
Unload frmGame
End Sub

But I get this error that says Winsock isn't connected and highlights this line:


Code:
frmGame.Winsock.SendData "logd¿"

Does DX make winsock disconnect? If not, why does it say I'm disconnected?

ISP 2hr Disconnect
Hi all, wondering if anyone had any ideas on a little problem i'm having. I've written a game using DirectPlay, quite successfully, apart from one little problem - my ISP disconnects me after 2hrs, which is very frustrating. Once this happens the game crashes and i'm not sure where, but that isn't what is bugging me.

The question i'm asking is - is there anyway of detecting this and does anyone know of a work around so the player may rejoin in the same place (or as near as) before disconnection occured??

Thanks in advance

Disconnect Aol?
my friend asked me to make him a program that iwll dissconnect him from aol at a certin time, and i'm done except i can't find a function to disconnect from aol.. any ideas?

FTP API Disconnect
I am successfully using the sample code from mentalis.org to process files. Problem is, when I disconnect using the InternetCloseHandle, my FTP server shows that I am still logged in. Its seems I am just cutting the connection as oppsed to correctly logging off. How can I use the API to send the "bye" command or somehow correclty logoff my current session?

Here is my open and close code:

Code:
Public Sub FTPOpen(site$, login$, password$)
'open an internet connection
hOpen = InternetOpen(App.title, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
'connect to the FTP server
hConnection = InternetConnect(hOpen, site$, INTERNET_DEFAULT_FTP_PORT, login$, password$, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
'create a buffer to store the original directory
sOrgPath = String(MAX_PATH, 0)
'get the directory
End Sub

Code:
Public Sub FTPClose()
'close the FTP connection
InternetCloseHandle hConnection
'close the internet connection
InternetCloseHandle hOpen
End Sub

Thanks,

Rob

Disconnect
Hey,there is there any code out there to disconnect dial up from the net wen i press disconnect then it will disconenct me thank u

Disconnect Net
Can someone give me the code to disconnect internet from the pc?Thanks in advance for any reply.

Is There A Way To Disconnect Winsock?
ok when someone leaves my one on one chat i send a command saying///left the client sees this and then disconnects winsock but how do i do this is there a something like

winsock.disconnect?

Disconnect And Connect
how do i order cmdconn to connect and cmddis to disconnect to the internet??

How Do I Disconnect From The Internet?
Hello!

I was wondering, how would I make my application drop a dialup connection from the Internet? I am making this application for a friend who wants an internet time monitor.

Thanks!
<font color=red>Alphanumeric</font color=red>

Disconnect From Internet
what is the easiest way for me to simply disconnect my adsl connection. I have to dial up to connect and I would like to be able to disconnect with a click of a button in my program.

Disconnect A Webcam
i was searching the forum but i couldn't find anything about diconnecting a webcam without shutting down the program
anyone know how to discconect a webcam in the program

thx

Disconnect Database
i use a defaul jet engine to connect my access database.
how can i disconnect from database in a form , so i can use filecopy ??
is there a simple command to do that ?

from emidio.

Disconnect A Recordset
I've got 2 database, that are exactly the same. Both of them contain records in the 'Customer' table. Now I want add the records from database1 to database2, but first I want to check whether the record from database1 already exists in database2.
I use the code mentioned here.

rstLocal.Open sqlStr, connLocal, adOpenForwardOnly, adLockOptimistic
rstCentral.Open "SELECT * FROM Customer, connCentral, adOpenStatic, adLockOptimistic
sqlStr = "SELECT * FROM Customer WHERE false"
rstNew.Open sqlStr, connLocal, adOpenForwardOnly, adLockOptimistic
rstDouble.Open sqlStr, connLocal, adOpenForwardOnly, adLockOptimistic

Set rstNew.ActiveConnection = Nothing
Set rstDubbel.ActiveConnection = Nothing
Do While Not rstLocal.EOF
sqlStr = setSQL
Set rstCentral = New ADODB.Recordset
rstCentral.Open sqlStr, connCentral, adOpenStatic, adLockOptimistic
If rstCentraal.RecordCount > 0 Then
addRecToRst rstDouble, rstLocal, tabel
Else
addRecToRst rstDouble, rstLocal, tabel
End If
rstLocal.moveNext
Loop

I want to cycle through rstLocal (database1) and see if a record already exists in database2. When it does I want to add that record to a recordset called rstDouble (which has the same structure and is empty). I don't want to add this to the database, only in the recordset. I know that it has to be disconnected, but somehow I can't figure out how to do that right.
The bold lines give me a 3705 error (Can't perform while object is still open, or something like that). I hope I've made clear what's the problem here. All help is welcome.

Disconnect From A Database
Hi everybody

I made a little application connecting on a database like that:

Code:
Private dbWorkspace As Workspace
Private dbDatabase As Database
Private dbTable As Recordset

'Connect to the DataBase
Set dbWorkspace = DBEngine.Workspaces(0)
Set dbDatabase = dbWorkspace.OpenDatabase("C:DataBase.mdb")
Set dbTable = dbDatabase.OpenRecordset("TheTable", dbOpenTable)

After that I'm able to do some operation on it but I don't know how to disconnect form it without closing the application

Someone know???


Thank you very much

How To Disconnect Adodc?
I have placed some ADODCs in some forms of my VB6 project. These forms are child forms under a MDI container. I am using Sybase SQL Server 11.1.3.1 as backend database. TDB Grid dropdowns are used as bound data control for those ADODCs. In form load event I establish the database connection of the ADODCs via connection string. The recordsource of the ADODCs are changed several times according to the situation during the lifetime of the form. But after unloading the form, those db connections remain unclosed. Additionally, for each refresh method is increasing db connections. This situation is causing enormous open db connections. Is there any way to disconnect the db connections, created by ADODCs, at the form unload event? Unbinding the TDB Grid drop downs doesn't solve the problem. I am using MDAC 2.6. Can anybody help me in this?

Disconnect Recordset
1. what is it?
2. can it be used for client/server app?

thx

USB Connect / Disconnect
Hi,
I'm using a software (not mine) connected to a USB device.
This software should be PERMANENTLY or AS often as possible connected to the device.

The problem is that sometimes the device get crashed :
If i reboot (Start->restart), and i tried to re-connect it doesn't work.

If i unplug the USB cable and plug it back it works !

My question is : If I programmatically unplug/plug the USB : force a new detection will it work and how to do it ?

I really need help ! Thanks !

Dial-Up Disconnect
I'm using the wininet.dll to connect to the net automatically.

How do I close this connections?

Connect / Disconnect From LAN
Hello,

My computer is connected to a LAN. Can anyone please suggest me an API that will allow me to connect and disconnect my computer (internet services, in particular) from a LAN?

Thanks for your time,
Manish

How To Disconnect Internet
i made a program using winsock to send and receive mail from my mailserver.. Automaticly i will get the connection with internet... How i do turn off this connection when i finish reading/sending my mail

you're help will be welcome!!
thanks Ton

Copyright © 2005-08 www.BigResource.com, All rights reserved