ArduPilot / node-mavlink

This project is providing native TypeScript bindings and tools for sending and receiving MavLink messages over a verity of medium
GNU Lesser General Public License v3.0
75 stars 25 forks source link

Serialization error regarding uint64_t type fields #13

Closed SKYnSPACE closed 2 years ago

SKYnSPACE commented 2 years ago

Whenever I try to serialize a payload containing uint64_t field, such as SystemTime(#2) in the common dialect, the following error arises:

node:internal/buffer:581 let lo = Number(value & 0xffffffffn); ^ TypeError: Cannot mix BigInt and other types, use explicit conversions at writeBigU_Int64LE (node:internal/buffer:581:25) at Buffer.writeBigUInt64LE (node:internal/buffer:601:10)

Are there any other protocols to follow to handle the types in 64 bits? Thank you :)

padcom commented 2 years ago

64-bit numbers in Node.js are represented with BigInt. Check out the docs at https://developer.mozilla.org/pl/docs/Web/JavaScript/Reference/Global_Objects/BigInt to learn how to deal with those values.

padcom commented 2 years ago

It essentially means you need to use the n suffix :)

image

SKYnSPACE commented 2 years ago

Not giving any value to the time_usec (uint64_t) field produces the same error. Setting msg.timeUsec to 0n solved the issue.

Thanks a lot 👍👍👍👍👍