I have my GPS and 6DOF boards reading and logging to the SD card on my Domino. Lots of fun and pretty.
Now I want to write to the GPS to increase the update rate (which also requires a baud increase). The format is SkyTrac Binary. There is a link to the reference below which indicates a binary/hex message format.
I have a bunch of conceptual questions that hopefully someone can answer:
[ulist]what format am I writing back in Char/byte/string? Not understanding how I send a HEX character I guess.
when I change the baud rate I assume I need to close and then reopen the connection? how do I even get the ACK back if the baud has changed
any sample code would be helpful - I have looked around but not found any
[/ulist]
I read the C# documentation…are you referring to something else?
Serial Port has three write methods - string, byte and char.
are you saying that I can pass it a string and it will automatically cast/convert it to bytes and then send bytes? That would be cool - but its not clear that this is what happens in the docs to me.
I have read the eBook about 4 times - it is really awesome at getting the high level concepts down…
This being said - there is nothing in the eBook that explains the difference between:
[ulist]Write(String) Writes the specified string to the serial port.
Write(Byte[], Int32, Int32) Writes a specified number of bytes to the serial port using data from a buffer.
Write(Char[], Int32, Int32) Writes a specified number of characters to the serial port using data from a buffer. [/ulist]
And under what circumstances to use each.
What I am hearing you say is ‘Just use Byte Arrays’ - Putting Chars and Strings through a Serial port is stupid.
As for the PC interface - I wanted to make something a little more robust that could check the rates and update them if they ‘get off spec’.
[quote][Write(String) vs Write(Char[], Int32, Int32)]
And under what circumstances to use each.[/quote]
It’s like the difference between the number 10 and the roman numeral X. Or hex 0x0A. They’re just different ways of representing the exact same data.
If your code has a string that it wants to stuff into the serial port, you’d use the Write(string) version. If it happened to have an array of chars instead, the Write (char[], …) version would be the one to use.
Underneath, the different versions of Write are pretty much identical. They’re just starting with different ways of identifying the same stream of bytes.