I am a beginner with mavlink and even pixahawk. I need to just parse mavlink data coming from pixahawk. (Mavlink v1, pixahawk v5plus), on Linux PC (Ubuntu). I have 2 processes in context of this question. (The Pixahwak is already cofigured to send some messages HEARTBEAT, ATTITUDE etc).
I have written C code that reads serial port data which gets mavlink v1 data from telemetry1 port of pixhackv5plus and saves each byte by byte in shared memory segment created using shmget()/shmat(). That shared memory segment remains intact even after this process exits.
Now, I run another process that reads data from this shared memory buffer and parses byte by byte. This parser process has not been completely written by me but I took code from
https://github.com/mavlink/c_uart_interface_example and for mavlink v1, reusing c library from https://github.com/mavlink/c_library_v1 (My pixahawk sends Mavlink v1 data).
In file serial_port.cpp in c uart example above, I have removed code that calls read(fd..) but taking shared memory data byte by byte and passing to mavlink_parse_char().
This is not working, I am getting msgReceived as false through out, though I know
this data contains valid mavlink messages.
Am I right in this methodology? Please guide. Once this works, I have to replicate parser on an embedded platform, in C.
Code for reading serial data from pixhack at:
https://github.com/developb/mavlink_read_buffer/blob/master/main_rx.c
Code where data(each byte) is read from shared memory and fed to mavlink_parse_char() is at: https://github.com/developb/mavlinkv1_parse_v0/blob/master/serial_port.cpp
Here, this is the line I modify that makes each byte be taken from shared memory instead of serial port:
int result = _read_port(cp);
//cp = (unsigned char)(*(unsigned char*)shm_current_addr_temp);