I'm improving and now i'm trying and I'd like to estabilish a connection between 2 devices also if it's not very simple for me.
Wrong answer!
Your problem is you have no idea how to call some very simple function with very good described parameter list!
so why do you have such a problem?
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...
You really, really cannot pick this up as you go along without having a very good grounding in the basics of the c++ language, which is obvious you do not have. You need to start with the very basics and progress one step at a time. You are trying to undertake the triple jump without knowing how to run.
OK thank you very much! Also if the problem is to send this packet: 0x01, 0x01, 0x01 , 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00. Not an Array of char.
This says that ptr is a pointer to memory containing unsigned characters and that the characters pointed to cannot be changed. An area of memory containing unsigned characters is a character array (or an array of chars). So to use StuffData the first parameter has to be a pointer to an array of chars. So before you call the function StuffData, your program has to put into a char array the characters for StuffData. You cannot get away from not using a character array! This can be either a fixed size array (as in my previous example) or it can be a dynamically allocated memory (use new). However the character array is created, once it has been you need to populate it with the characters for StuffData.
So from your example, you want to use 11 characters. So you need a character array that contains these characters set up before you call StuffData.
I tried before to write!!! but it doesn't work (I have errors when it compiles or i read very strange characters) and for this reason I want to know if it is correct...
I tried before to write!!! but it doesn't work (I have errors when it compiles or i read very strange characters) and for this reason I want to know if it is correct...
So do you have some errors (compile, link, run-time) or not?
The destination characters returned by StuffData in dst are NOT a c-style string and are NOT guaranteed to be NULL terminated. So using printf (or cout) to try to display the contents of dst is a non-starter. Have you actually looked at what StuffData does? It takes an array of char and a length and returns a codified char array where the first char is the number of bytes (including itself) followed by the chars. If the length of the bytes exceeds 255 then a new chuck is started again with the first byte as the length byte. So "qwerty" gets codified as 0x07 'q' 'w' 'e' 'r' 't' 'y'. 0x00 is treated specially and just gets translated as a new chuck of length 1. So after using StuffData, you pass dst to whatever function you use to actually send the data.
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
The destination characters returned by StuffData in dst are NOT a c-style string and are NOT guaranteed to be NULL terminated. So using printf (or cout) to try to display the contents of dst is a non-starter.
I'd say neither the initial buffer nor the destination one is "a c-style string". Both are just byte sequences with some predefined length.
And there is nothing wrong to use printf (or cout) to output their contents. Just use some proper format specification (like %X, "%08X", "%d" or similar) and do output in a loop for each element in the buffer!
Bookmarks