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:
PHP 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!
Well, then try to encode your byte sequence using this code according to this comments:
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".
*/
Then send theough the port the encoded byte sequence pointed to by "dst"
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.
I have some problems...I'm a new programmer and all codes are not simple for me now. Are there some example code to understand how i can do it?
Thank you and I'm sorry.
I have some problems...I'm a new programmer and all codes are not simple for me now. Are there some example code to understand how i can do it?
Thank you and I'm sorry.
Well, did you read some books about progamming with C++ for Windows?
Did you try some simple sample applications like "Hello Worlds"?
Some others a little more complicated?
Note, that you cannot from the level "zero" jump to a level for programming serial port communications...
So...
Bookmarks