chutsu / ubx

u-blox protocol parser and RTK GPS server client
MIT License
2 stars 3 forks source link

trying to use your code #1

Closed elgarbe closed 2 years ago

elgarbe commented 2 years ago

Hi, I'm trying to use part of your code on an embedded system. I manually config F9P's UART1 to output UBX-NAV-RELPOSNED, UBX-NAV-PVT and UBX-NAV-HPPOSECEF, the connect F9P to my uC (STM32F722) and import some part of your code. I configure 1 byte circular DMA reading and on each incoming byte I call:

      if (ubx_parser_update(&parser, rxbuff) == 1) {
          HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin);
          ubx_msgids[idx] = parser.msg.msg_id;
          idx++;
          if(idx==100)
              idx=0;
      }

I put a breackpoint on idx=0 line and check ubx_msgids array, they are filled with 0x07 and 0x3c so the parser is parsing ok two messages.

But, now I would like to use the payload in order to fill a ubx_nav_pvt_t variable. The function ubx_nav_pvt_t ubx_nav_pvt(const ubx_msg_t *msg) expect a ubx_msg_t instead of a ubx_parser_t

I don't understand how ubx_msg_t is managed on your code and if it's easy to modify the code for my use case.

Thank

chutsu commented 2 years ago

Sorry I don't know why I didn't get notified.

Once the UBX binary data is obtained I used ubx_msg_parse(ubx_msg_t *msg, const uint8_t *data) to convert the bytes in data to a ubx_msg_t. From there you can convert the generic ubx_msg_t to anything that it represents, in your case it would be ubx_nav_pvt_t.

Hope that helps :)