The connection between bluetooth device and PC is working.
In the code of http://www.naughter.com/serialport.html there is the app.cpp code. When it runs the port is opened and the connection is made but after some seconds appears this error:
CSerialPort::Write, Failed in call to WriteFile, Error:997
ERROR_IO_PENDING (error 997) just means that Write operation is not completed yet! From MSDN:
... GetLastError function returns ERROR_IO_PENDING. This allows the calling process to continue processing while the write operation is being completed. The event specified in the OVERLAPPED structure is set to the signaled state upon completion of the write operation.
thank you very much Victor for your help! I'm a new programmer, but i'm improving and the communication between PC and device has been established also with C++ language. I discovered that I have problems with writefile becouse the device bluetooth use Cobs codification and now I'm trying to understand the following Cobs code:
* StuffData byte stuffs "length" bytes of
* data at the location pointed to by "ptr",
* writing the output to the location pointed
* to by "dst".
Sorry, but I have no idea what these FinishBlock macro and StuffData function are for and where they come from...
BTW, you should use Code tags (using # toolbar button) rather than PHP or HTML ones.
Besides, your code is very bad formatted: messed indentations and more than one statement on the same line make reading/understanding this code very difficult!
You have to declare a destination buffer long enough to contain your encoded byte sequence, then call this StuffData function passing in your original byte array, its length and destination buffer.
Then send what destination buffer will get after this function returns to the serial port.