Skip to content

Commit

Permalink
adding rl6 ucm information to IE FCM 804 (#320)
Browse files Browse the repository at this point in the history
* adding rl6 ucm information
* fixing linter's requirements
  • Loading branch information
nkrasko authored Nov 26, 2024
1 parent a97c634 commit 56d919c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 11 additions & 4 deletions fuel_cells/intelligent_energy_fcm_804_can/firmware.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local config = require('enapter.ucm.config')

INDEX_CONFIG = 'index'
SAVE_0x400_CONFIG = 'save_0x400'
RL6_CONFIG = 'rl6'

VENDOR = 'Intelligent Energy'
MODEL = 'FCM 804'
Expand All @@ -18,6 +19,7 @@ cd_alerts = nil

can_index = 1
save_0x400 = false
rl6 = nil
messages_0x400 = {}

function main()
Expand All @@ -32,6 +34,7 @@ function main()
config.init({
[INDEX_CONFIG] = { type = 'number', default = 1, required = true },
[SAVE_0x400_CONFIG] = { type = 'boolean', default = false },
[RL6_CONFIG] = { type = 'string' },
}, {
after_write = setup_options,
})
Expand All @@ -47,6 +50,7 @@ end
function setup_options(args)
can_index = args[INDEX_CONFIG]
save_0x400 = args[SAVE_0x400_CONFIG]
rl6 = args[RL6_CONFIG]
configured = true
end

Expand All @@ -57,6 +61,11 @@ function send_properties()
info['serial_number'] = serial_number
is_serial_number_completed = false
end

if rl6 ~= nil and rl6 ~= '' then
info['rl6'] = rl6
end

info['fw_ver'] = fw_ver

enapter.send_properties(info)
Expand All @@ -73,8 +82,7 @@ function send_telemetry()
local str_0x400
for _, data in pairs(messages_0x400) do
str_0x400 = str_0x400 or ''
local str_0x400_part =
string.format('%02x%02x%02x%02x%02x%02x%02x%02x', string.unpack('I1I1I1I1I1I1I1I1', data))
local str_0x400_part = string.format('%02x%02x%02x%02x%02x%02x%02x%02x', string.unpack('I1I1I1I1I1I1I1I1', data))
str_0x400 = str_0x400 .. ' ' .. str_0x400_part
end
telemetry['messages_0x400'] = str_0x400
Expand Down Expand Up @@ -105,8 +113,7 @@ function can_handler(msg_id, data)
if not is_serial_number_completed then
if string.byte(data, 1) > 127 then
if #temp_serial_number == 8 then
local serial_number_part =
string.char(string.byte(data, 1, 1) - 128, string.byte(data, 2, 8))
local serial_number_part = string.char(string.byte(data, 1, 1) - 128, string.byte(data, 2, 8))
temp_serial_number = temp_serial_number .. serial_number_part
serial_number = temp_serial_number
is_serial_number_completed = true
Expand Down
7 changes: 7 additions & 0 deletions fuel_cells/intelligent_energy_fcm_804_can/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ properties:
fw_ver:
type: string
display_name: Firmware Version
rl6:
type: string
display_name: Control RL6 UCM ID

telemetry:
status:
Expand Down Expand Up @@ -131,6 +134,10 @@ commands:
display_name: Troubleshooting Mode
description: Save troubleshooting CAN messages (0x400) for further analysis by Intelligent Energy service team.
type: boolean
rl6:
display_name: Enapter RL6 UCM ID Used for Control
description: If you use RL6 UCM for control signals, put it ID in this field for better integration
type: string
read_configuration:
display_name: Read Configuration
group: config
Expand Down

0 comments on commit 56d919c

Please sign in to comment.