Skip to content

Commit 7e45977

Browse files
committed
feat(generic-can): pass msg_ids as coma-separated string
1 parent 77234ce commit 7e45977

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

spec/generic_can_spec.lua

+5-9
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@ describe('generic can', function()
2727

2828
it('shoud execute read command when setup', function()
2929
local messages = {
30-
{ msg_id = 0x123 },
31-
{ msg_id = 0x789 },
30+
{ msg_id = 123 },
31+
{ msg_id = 789 },
3232
}
3333
local timeout = math.random(5000)
3434

3535
local peer_stub = prepare_peer_stub()
3636
local s = spy.on(peer_stub, 'execute_command')
3737
assert.is_nil(can:setup('', { test_cmd = messages }, timeout))
3838
assert.spy(s).was_called(1)
39-
assert
40-
.spy(s)
41-
.was_called_with(peer_stub, 'read', match.same({ msg_ids = { 0x123, 0x789 } }), { timeout = timeout })
39+
assert.spy(s).was_called_with(peer_stub, 'read', { msg_ids = '123,789' }, { timeout = timeout })
4240
end)
4341

4442
it('should store cursor', function()
@@ -51,9 +49,7 @@ describe('generic can', function()
5149
local _, err = can:get('test_cur')
5250
assert.is_nil(err)
5351
assert.spy(s).was_called(1)
54-
assert
55-
.spy(s)
56-
.was_called_with(peer_stub, 'read', match.same({ msg_ids = {} }), { timeout = 1000 })
52+
assert.spy(s).was_called_with(peer_stub, 'read', { msg_ids = '' }, { timeout = 1000 })
5753

5854
peer_stub = prepare_peer_stub()
5955
local s2 = spy.on(peer_stub, 'execute_command')
@@ -62,7 +58,7 @@ describe('generic can', function()
6258
assert.spy(s2).was_called(1)
6359
assert
6460
.spy(s2)
65-
.was_called_with(peer_stub, 'read', match.same({ cursor = cursor, msg_ids = {} }), { timeout = 1000 })
61+
.was_called_with(peer_stub, 'read', { cursor = cursor, msg_ids = '' }, { timeout = 1000 })
6662
end)
6763

6864
it('should not get for unknow subscription', function()

src/enapter/ucm/generics/can.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local function extract_msg_ids(messages)
66
for _, msg in ipairs(messages) do
77
if msg.msg_id then table.insert(msg_ids, msg.msg_id) end
88
end
9-
return msg_ids
9+
return table.concat(msg_ids, ',')
1010
end
1111

1212
local can_read = function(self, name)

0 commit comments

Comments
 (0)