I am trying to replace a serial cable with a bluetooth "connection". I am only sending characters from the desktop to a device.
I and running XP and VB5.0.
I can get it to work sometimes but things always fall apart.
(1) When I plug the dongle into a USB port I can use the Windows Device manager to see two new comm ports show up. The bluetooth icon also appears in the task bar. If I click on it I see two commports, one for incoming and one for outgoing. Sometimes they are com3 and com4 respectively, other times they are com4 and com3. If I unplug the dongle and plug it back, I might get com4 and com9.
(2) When I run my VB program I put in a combobox that when clicked attempts to open all commports from 1 to 9.
Private Sub cmbCommPorts_GotFocus()
'When focused, get a list of existing commport numbers
cmbCommPorts.Clear
For I = 1 To 9
On Error Resume Next
MSComm1.CommPort = I
On Error Resume Next
MSComm1.PortOpen = True
On Error Resume Next
MSComm1.PortOpen = False
If Err.Number = 0 Then
cmbCommPorts.AddItem ("com"+Str(I)))
End If
Next I
End Sub
(3) It lists the ones it finds and lets the user select the "right one". But the VB program can't tell which is the incoming and which is the outgoing. I can tell that when I used the bluetooth icon (step 1) so I select the "right one".
Things will be fine then, suddenly the transmissions stop. I check the bluetooth icon and see that the outgoing port is not listed. It still is in the Device Manager though. I can then do some playing around with "add a Bluetooth device" (like step 1 all over again) and I'll get the outgoing port to show again. But perhaps it was com4 before and now it might be com8.
Then if I go to the combobox, the outgoing port won't list (as in step 2). Only com1 (my old RS232 port) and com3, the incoming bluetooth port. I can restart the program and still it won't find the outgoing port. I have to reboot the computer for step 2 to find the outgoing port.
So, why does the outgoing port disappear?
So, how can I tell which of the ports is the outgoing and incoming?
So, how can I get VB to find the port that went away and then I got back?
Thanks in advance,
Pete
I and running XP and VB5.0.
I can get it to work sometimes but things always fall apart.
(1) When I plug the dongle into a USB port I can use the Windows Device manager to see two new comm ports show up. The bluetooth icon also appears in the task bar. If I click on it I see two commports, one for incoming and one for outgoing. Sometimes they are com3 and com4 respectively, other times they are com4 and com3. If I unplug the dongle and plug it back, I might get com4 and com9.
(2) When I run my VB program I put in a combobox that when clicked attempts to open all commports from 1 to 9.
Private Sub cmbCommPorts_GotFocus()
'When focused, get a list of existing commport numbers
cmbCommPorts.Clear
For I = 1 To 9
On Error Resume Next
MSComm1.CommPort = I
On Error Resume Next
MSComm1.PortOpen = True
On Error Resume Next
MSComm1.PortOpen = False
If Err.Number = 0 Then
cmbCommPorts.AddItem ("com"+Str(I)))
End If
Next I
End Sub
(3) It lists the ones it finds and lets the user select the "right one". But the VB program can't tell which is the incoming and which is the outgoing. I can tell that when I used the bluetooth icon (step 1) so I select the "right one".
Things will be fine then, suddenly the transmissions stop. I check the bluetooth icon and see that the outgoing port is not listed. It still is in the Device Manager though. I can then do some playing around with "add a Bluetooth device" (like step 1 all over again) and I'll get the outgoing port to show again. But perhaps it was com4 before and now it might be com8.
Then if I go to the combobox, the outgoing port won't list (as in step 2). Only com1 (my old RS232 port) and com3, the incoming bluetooth port. I can restart the program and still it won't find the outgoing port. I have to reboot the computer for step 2 to find the outgoing port.
So, why does the outgoing port disappear?
So, how can I tell which of the ports is the outgoing and incoming?
So, how can I get VB to find the port that went away and then I got back?
Thanks in advance,
Pete