Jeff Barnes wrote:I wonder if this could be because the COM ports I am working with are Bluetooth Serial Ports??????
I'm with James. I know nothing about Bluetooth, sorry. That could be the problem.
EMG
Jeff Barnes wrote:I wonder if this could be because the COM ports I am working with are Bluetooth Serial Ports??????
In device manager the bluetooth com ports are listed as:
"Standard Serial over Bluetooth link (COM4)"
Is there any other way to send data to a serial port?
"Standard Serial over Bluetooth link (COM4)"
As far as I know, they act as standard serial ports.
The device itself, communicates over bluetooth via a typical serial connection.
What I am trying to do is give the user the ability to "search" for the device.
I check windows registry to see what available com ports there are.
Then I want to be able to send the connection command (D8) to the device.
If I get a reply (06) the device has been found. If not, it should "timeout" and then move to the next com port in the list.
It will not "timeout" when it sends the command to a com port that has nothing paired to it.
It would be nice if WriteComm() had a timeout parameter ![]()
I remember trying HBCOMM before (quite a while ago) but I was not able to get it working.
I'd try it again but I can't locate hbcomm files.
As far as I know, they act as standard serial ports.
I will have to try this on a pc with a standard com port and see if it makes any difference although that won't solve my problemJeff Barnes wrote:It will not "timeout" when it sends the command to a com port that has nothing paired to it.
It would be nice if WriteComm() had a timeout parameter
When I say I want to try it on a pc with a "standard serial port" I mean a physical com port with the DB9 connector.
I say "As far as I know" because I use the same code when connecting to a hardwired device.
When the device is on the com port (either hardwired or bluetooth) WriteComm() works just fine.
The bluetooth serial is not a bluetooth device connected to a serial port (DB9) but rather a bluetooth adapter (USB) that communicates via serial data.
As far as the computer is concerned the bluetooth COM port should be no different than a physical (DB9) COM port.
I hope that clears thing up ![]()
BuildCommDcb( "COM4:9600,N,8,1", @cDcb )IF ! BuildCommDcb( "COM4:9600,N,8,1", @cDcb )
MsgInfo("BuildCommDCB Error")
ENDIFJeff,
Sorry, I meant:
"Your problem starts back to SetCommState(). It fails, so WriteComm() freezes."
EMG
Jeff Barnes wrote:Now I try it this way and BuildCommDcb will show the error message but still connects when the device is available.
How can it fail but still read/write to the com port ????
IF ! BuildCommDcb( "COM4:9600,N,8,1", @cDcb ) MsgInfo("BuildCommDCB Error") ENDIF
I realize that if I use the "IF ! BuildCommDcb....." I should exit the routine but why does it work if BuildCommDcb fails?????
Is there something wrong with my BuildCommDcb statement?
Enrico,
According to his signature line, he is using:
(FWH 12.01, xHarbour 1.2.1, Bcc582)
So, it is two years old.
James
Jeff,
OK, now I get it. You are checking USB ports NOT serial ports.
I didn't even know you could use COM addresses for that. I have never done any communication with USB ports via FWH before, so can't be of much help with this.
I do note that my two USB ports show under a different category than my single comm port in the Control Panel. If my USB ports have a COM address, how would I find out what they are. My serial port is listed as COM1. Do I assume that the USB ports are COM2 and COM3?
OK, I tried the test program on COM2 and COM3 it gives the "SetCommState Error" on both attempts. Note that I have a wireless mouse adapter on one of the USB ports. The other USB port is empty. So, I am still not getting a hang.
James
Jeff,
Here is an old thread discussing issue with USB comms which may be of help.
viewtopic.php?f=3t=20028p=106071hilit=usb#p106071
James
&&&
James Bott wrote:Enrico,
According to his signature line, he is using:
(FWH 12.01, xHarbour 1.2.1, Bcc582)
So, it is two years old.
James
#include "Fivewin.ch"
Function FindCom()
LOCAL cDCB, nComm, cInit
nComm:= OpenComm("COM4", 16384,16384 )
IF nComm < 0
MsgInfo("Error opening port")
RETURN NIL
ENDIF
cInit := "COM4:9600,N,8,1"
IF BuildCommDcb( cInit, @cDcb )
MsgInfo("BuildCommDcb Error")
CloseComm(nComm)
Return Nil
ENDIF
IF ! SetCommState( nComm, cDcb )
MsgInfo("SetCommState Error")
CloseComm(nComm)
RETURN NIL
ENDIF
MsgInfo("Just before writing to com port")
IF ! SendStr( nComm, "D8" )
MsgInfo("No Connection but passed problem with locking up") //never gets this far
ENDIF
MsgInfo("After writing to com port")
Return Nil
STATIC FUNCTION SendStr( nComm, cString )
RETURN WriteComm( nComm, cString ) = LEN(cString)