Just brought the file machine_can.c from the fork
https://github.com/nos86/micropython/tr ... can-driver
into the MicroPython V1.13 project compiled with esp-idf-v4.0.1.
There were some minor adaptions to macro usage around error strings with MP_ERROR_TEXT necessary and I also changed the constant mentioned in the single PR 'Fix CAN std id length 11 bit' on the project of nos86. Also don't forget to adjust the modmachine.c/h files with the incantation for the CAN module like
Code: Select all
for modmachine.c
:
{ MP_ROM_QSTR(MP_QSTR_TouchPad), MP_ROM_PTR(&machine_touchpad_type) },
{ MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&machine_adc_type) },
#if MICROPY_HW_ENABLE_CAN
{ MP_ROM_QSTR(MP_QSTR_CAN), MP_ROM_PTR(&machine_can_type) },
#endif
{ MP_ROM_QSTR(MP_QSTR_DAC), MP_ROM_PTR(&machine_dac_type) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_i2c_type) },
:
for modmachine.h
:
extern const mp_obj_type_t machine_rtc_type;
extern const mp_obj_type_t machine_sdcard_type;
extern const mp_obj_type_t machine_can_type;
:
Enabling the compilation and inclusion of the CAN module can then be managed by having
in mpconfigboard.h for whatever board you compile MicroPython.
After that the CAN module comes up when issuing
Further testing is needed for sure, but so far so good, I'll report back when I can connect to my Sol-Ark 12K inverter via CAN.