![]() ![]() can be turned into something like this: for (int i=0 i<< "\ncomputed checksum: " << std::hex << (int)check << "\n" The NMEA string checksum is automatically computed and appended to string when using the InertialSense SDK serialPortWriteAscii function or can be generated using an online checksum calculator. See NMEA 0183 message structure for more details. Std::cout << "received checksum: " << received_checksum The checksum is always lowercase hexadecimal characters. Print out both the received and computed checksums: Save the checksum that was at the end of what we received.Ĭhar check = std::accumulate(sentence.begin()+1, sentence.end(), 0, My immediate reaction would be to write code something like this: #include I believe this can be simplified quite a bit. Ifstream Cheat1("Amateur Hour.txt", ios::in | ios::binary) Ofstream Cheat("Amateur Hour.txt", ios::out | ios::app) Hex Checksum to Binary Conversion (messy, but does the job) ![]() Store individual characters in an element of an vector Here's an example of the type of message: !AIVDM,1,1,A,13HOI:0P0000VOHLCnHQKwvL05Ip,0*23 Is there a better way of handling the "Store individual characters in vector" section? I went that way because the message can be of variable size (plus 1 or 2 characters). I tried for a good day to do it with tables etc, but in frustration I ended up going with this. In particular, the hex-to-binary section, the checksum is in hex, and the rest is in ASCII. I was hoping for a bit of advice on cleaning a couple of areas of this code up. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |