Extending python with cpp modules is possible and well documented.
https://docs.python.org/3/extending/extending.html
Instead of programming CRC on your own, look for the boost CRC module which might already have a solution available.
The cpp code you show is named CO2ModbusComm::modbus_calcuCRC, so possibly related to modbus protocol.
Instead of using cpp module, you could fall back to a python implementation as found in https://pymodbus.readthedocs.io/en/late ... s.checkCRC
Keep in mind that just using any crc implementation found somewhere will most possibly not work. CRC algorithm on host side and sensor side must match. Refer to the datasheet of the sensor and see what is proposed there. There are a zillion of different CRC algorithms around (see https://crccalc.com/ ) plus a lot of implementations invented on the fly.
Is this post related to the other post viewtopic.php?t=362042#p2172061 ? If yes, then check your received data first.
https://docs.python.org/3/extending/extending.html
Instead of programming CRC on your own, look for the boost CRC module which might already have a solution available.
The cpp code you show is named CO2ModbusComm::modbus_calcuCRC, so possibly related to modbus protocol.
Instead of using cpp module, you could fall back to a python implementation as found in https://pymodbus.readthedocs.io/en/late ... s.checkCRC
Keep in mind that just using any crc implementation found somewhere will most possibly not work. CRC algorithm on host side and sensor side must match. Refer to the datasheet of the sensor and see what is proposed there. There are a zillion of different CRC algorithms around (see https://crccalc.com/ ) plus a lot of implementations invented on the fly.
Is this post related to the other post viewtopic.php?t=362042#p2172061 ? If yes, then check your received data first.
Statistics: Posted by ghp — Tue Dec 26, 2023 7:01 am