New topic in Networking: System.SerialPortCount, problem for Bluetooth Serial Module
roger - Thu Mar 27, 2008 7:46 pm <http://forums.realsoftware.com/viewtopic.php?t=21486> I'm using the following code to get a list of serial ports available on my system: Code:dim pn as integer = system.serialPortcount - 1 redim PortNames(pn) for i as integer = 0 to pn  Portnames(i) = System.SerialPort(i).Name next I then use this information to populate a PopupMenu. I recently started working with a Bluetooth Module from BlueRadios (http://www.blueradios.com/hardware_SC40.htm) for a project (on Windows XP) where we need to talk to a serial device wirelessly. These modules are great and require very little setup. They simply show up on the system as a serial port. RB's Serial control works great for that. However, I found that it has an issue with System.SerialPortCount. I stepped through my code, and I found that, when System.SerialPortCount is called, the system briefly connects to the device (one of the pins of the Bluetooth module is programmed to indicate a connection). When I try to connect to the module afterwards using Code:success = serial1.connect, success is false and serial1.LastErrorCode is 1168. After I reset the module and try to connect again, the connection is successful, and I can communicate with the module. From then on I can connect and disconnect as much as I want, It always works. Until I call System.SerialPortCount again, after which I get error 1168 again. System.SerialPortCount seems to be doing something that this Bluetooth module does not like at all. Anyone know what that could be? I have tried similar code in VB successfully. For comparison, I instantiated MSComm in an RB application to do the same. Since there doesn't seem to be an easy way to get a list of serial ports via MSComm, I'm using the following code to do that: Code:// detecting available serial ports PopupMenu1.DeleteAllRows for i as integer = 1 to 15  try   MSComm1.CommPort = i   MSComm1.PortOpen = true   PopupMenu1.AddRow "COM" + str(i)   MSComm1.PortOpen = false  catch   ' failed to open the port   ' do nothing  end next PopupMenu1.ListIndex = 0 This briefly connects to each port from 1 to 15 and adds the names of the ones it was able to connect to to the PopupMenu. This works fine and doesn't cause any error. I only seem to be having issues with System.SerialPortCount. If I don't call System.SerialPortCount in my app and just go ahead and connect to the module, it works fine. But once I call System.SerialPortCount, the module is in a weird state. I can't even use Hyperterminal or any other serial app to connect to it. The only thing that gets it out of this state is a reset of the module. Has anyone had similar issues talking to Bluetooth serial devices?
-- Over 900 classes with 18000 functions in one REALbasic plug-in. The Monkeybread Software Realbasic Plugin v8.1. <http://www.monkeybreadsoftware.de/realbasic/plugins.shtml> [email protected]
