AP_Periph Battery Cell Monitor not sending AUX CAN messages

Hi All,

I’m building an AP_Periph F303 based battery monitor but am having some trouble getting it to work correctly. My overall setup is an STM32F303 talking over SMBus (I2C) to an Atmel MCU which reads voltages etc and returns the correct values for each when requested.

When I plug my Atmel into a FC directly over i2c and set the BATT_TYPE to 7 (SMBus Generic) everything appears correctly on the ground station. I get overall pack voltage, individual cell voltages, current and temperature. This leads me to believe that the code I have custom written for the Atmel works so that the SMBus library is happy.

However when using an AP_Periph Can node in between the Atmel and the FC I start to get issues. I no longer get individual cell voltages, but the overall voltage is displayed for cell 1. Current and temperature work as expected. When looking at DroneCAN GUI I can see that I am getting “batteryinfo” messages correctly but no “batteryinfoaux” messages which contain the missing data but I just can’t work out why they aren’t sending!

I built a firmware based on the F303-periph which just uses the .inc file in my hwdef and an extra line to include battery support (is this correct or do I need some specific smbus define?)

include …/f303-periph/hwdef.inc
define HAL_PERIPH_ENABLE_BATTERY

I’ve done some digging around the code and added some debug statements, but I only understand the code flow enough to add that to the SMbus library, not into the CAN send library (where is that please?). I found ardupilot/Tools/AP_Periph/can.cpp which looks like it contains lots of constructors for packet types (including the normal batteryinfo) but none for batteryinfoaux.

I can see from the Atmel side that the CAN node is requesting the same hex codes through AP_Periph as a direct FC so I am thinking that I really need to start looking at the CAN sending side. Any advice?

Byte requests from AP_Periph on boot: