def test_build_bcm_update_header(self): can_id = 0x401 flags = 0 bcm_buffer = build_bcm_update_header(can_id=can_id, msg_flags=flags) result = BcmMsgHead.from_buffer_copy(bcm_buffer) self.assertEqual(CAN_BCM_TX_SETUP, result.opcode) self.assertEqual(flags, result.flags) self.assertEqual(0, result.count) self.assertEqual(0, result.ival1_tv_sec) self.assertEqual(0, result.ival1_tv_usec) self.assertEqual(0, result.ival2_tv_sec) self.assertEqual(0, result.ival2_tv_usec) self.assertEqual(can_id, result.can_id) self.assertEqual(1, result.nframes)
def test_build_bcm_transmit_header_initial_period_0(self): can_id = 0x401 flags = 0 count = 42 bcm_buffer = build_bcm_transmit_header( can_id=can_id, count=count, initial_period=0, subsequent_period=2, msg_flags=flags, ) result = BcmMsgHead.from_buffer_copy(bcm_buffer) self.assertEqual(CAN_BCM_TX_SETUP, result.opcode) # SETTIMER and STARTTIMER should be added to the initial flags self.assertEqual(flags | SETTIMER | STARTTIMER, result.flags) self.assertEqual(count, result.count) self.assertEqual(0, result.ival1_tv_sec) self.assertEqual(0, result.ival1_tv_usec) self.assertEqual(2, result.ival2_tv_sec) self.assertEqual(0, result.ival2_tv_usec) self.assertEqual(can_id, result.can_id) self.assertEqual(1, result.nframes)