The more I play with it, the more I'm thinking I'm sending data as unsigned integers when I shouldn't. I've also left comments in so hopefully following my thoughts is easier, and easier to correct misconceptions.
Code: Select all
uint8_t request = 0; //payload length for data requests
uint8_t MSP_Attitude = 108; //identification for requesting current mode
uint8_t kill = 1000; //change depending one what the AUX channel to disarm needs to be set to
uint8_t State = 0; //initialize variable to read incoming state stuff
int LED = 13;
void setup() {
Serial.begin(115200); //sets baud rate
}
void loop() {
//////////////Begin Serial Transmit Communication module////////////////////////
uint8_t checksum = 0; //initialize checksum
Serial.write((byte *)"$M<", 3); //sends breamble bytewise 3 is number of bites used
Serial.write(0); //sends length of payload (0 for requests, replace n_bytes as needed)
checksum ^= 0; //updates checksum
Serial.write(MSP_Attitude); //writes request/command
checksum ^= MSP_Attitude; //updates checksum
Serial.write(checksum); //sends checksum
I'm not entirely sure what is going on with the first line of Serial.write, but it seems to send what it should. I don't get a response from the flight control board though which is why I'm thinking I'm sending incorrect data in the next 6 lines.
Then before I have issues with it, I'm not entirely sure how to compare what the flight control board sends back with set values in the Arduino. I've tried to get something to compile when I modified this
https://github.com/renes/multiwiiDataLo ... datalogger, but I honestly can't figure out what is going on.
I tried to just save the values that came into
https://github.com/renes/multiwiiDataLo ... protocol.h at lines 57 through 61, but I couldn't get anything to compile. It would compile without modifying it when I tried to compile the ones that only dealt with serial communications (protocol.cpp, protocol.h, and serialstate.h), so I'm thinking I'm not entirely understanding the Arduino programming either.
If I'm not mistaken, I do have to set up a loop to collect each byte of the serial communication individually then convert the array they end up in back into something readable. I'm not entirely sure how to do this, but I'll try different things once I get a response from the board. Right now my thinking is to read and watch for the $ then the M and finally the >, then loop through storing each bit that comes in and updating a checksum until the incoming byte equals the checksum.
In the MWOSD
https://github.com/ShikOfTheRa/scarab-o ... Serial.ino, I think it's reading the serial beginning at line 53, but I couldn't even figure out where to start when following what is going on with that so I gave up on that quickly.
I've also decided that to disarm the board, it would be easier to set up the Arduino between the receiver and the board on the channel used to arm/disarm and have it send the disarm value when needed.
Sorry for being abrupt with my questions, I'm just stressed out over it since I only have a week to get it figured out.
Edits: Just updating to follow the latest thing I did, switched from requesting Status to Attitude. And added current idea on how to actually read what is coming in, but that may be a question better suited for Arduino forums. Bit should be byte.