本文整理汇总了Python中pyipmi.msgs.encode_message函数的典型用法代码示例。如果您正苦于以下问题:Python encode_message函数的具体用法?Python encode_message怎么用?Python encode_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_readfrudatareq_encode_valid_req
def test_readfrudatareq_encode_valid_req():
m = pyipmi.msgs.fru.ReadFruDataReq()
m.fru_id = 1
m.offset = 0x302
m.count = 4
data = encode_message(m)
eq_(data, '\x01\x02\x03\x04')
示例2: test_writefrudatareq_encode_valid_req_wo_data
def test_writefrudatareq_encode_valid_req_wo_data():
m = pyipmi.msgs.fru.WriteFruDataReq()
m.fru_id = 1
m.offset = 0x302
m.data = array('B')
data = encode_message(m)
eq_(data, '\x01\x02\x03')
示例3: test_readfrudatarsp_encode_valid_rsp
def test_readfrudatarsp_encode_valid_rsp():
m = pyipmi.msgs.fru.ReadFruDataRsp()
m.completion_code = 0
m.count = 5
m.data = array('B', b'\x01\x02\x03\x04\x05')
data = encode_message(m)
eq_(data, '\x00\x05\x01\x02\x03\x04\x05')
示例4: test_setsensorthresholds_encode_req_set_unc
def test_setsensorthresholds_encode_req_set_unc():
m = pyipmi.msgs.sensor.SetSensorThresholdsReq()
m.sensor_number = 0x55
m.set_mask.unc = 1
m.threshold.unc = 0xaa
data = encode_message(m)
eq_(data, '\x55\x08\x00\x00\x00\xaa\x00\x00')
示例5: test_set_deactivation_lock_req
def test_set_deactivation_lock_req(self):
m = pyipmi.msgs.picmg.SetFruActivationPolicyReq()
m.fru_id = 1
m.mask.deactivation_locked = 1
m.set.deactivation_locked = 1
data = encode_message(m)
self.assertEqual(data, '\x00\x01\x02\x02')
示例6: send_and_receive
def send_and_receive(self, msg):
"""Sends an IPMI request message and waits for its response.
`msg` is a IPMI Message containing both the request and response.
"""
log().debug('IPMI Request [%s]', msg)
retries = 0
while retries < self.max_retries:
try:
rx_data = self._send_and_receive_raw(msg.target, msg.lun,
msg.netfn, chr(msg.cmdid) + encode_message(msg))
break
except TimeoutError:
pass
retries += 1
else:
raise TimeoutError()
msg = create_message(msg.cmdid, msg.netfn + 1)
decode_message(msg, rx_data[5:-1])
log().debug('IPMI Response [%s])', msg)
return msg
示例7: test_encode_req_set_ucr
def test_encode_req_set_ucr(self):
m = pyipmi.msgs.sensor.SetSensorThresholdsReq()
m.sensor_number = 0x55
m.set_mask.ucr = 1
m.threshold.ucr = 0xaa
data = encode_message(m)
self.assertEqual(data, '\x55\x10\x00\x00\x00\x00\xaa\x00')
示例8: test_chassiscontrol_encode_valid_req
def test_chassiscontrol_encode_valid_req():
m = pyipmi.msgs.chassis.ChassisControlReq()
m.control.option = 1
data = encode_message(m)
eq_(m.__netfn__, 0)
eq_(m.__cmdid__, 2)
eq_(data, '\x01')
示例9: test_setsensorhysteresis_encode_req
def test_setsensorhysteresis_encode_req():
m = pyipmi.msgs.sensor.SetSensorHysteresisReq()
m.sensor_number = 0xab
m.positive_going_hysteresis = 0xaa
m.negative_going_hysteresis = 0xbb
data = encode_message(m)
eq_(data, '\xab\xff\xaa\xbb')
示例10: test_getselentry_encode_valid_rsp
def test_getselentry_encode_valid_rsp():
m = pyipmi.msgs.sel.GetSelEntryRsp()
m.completion_code = 0
m.next_record_id = 0x0102
m.record_data = array('B', b'\x01\x02\x03\x04')
data = encode_message(m)
eq_(data, b'\x00\x02\x01\x01\x02\x03\x04')
示例11: test_encode_valid_rsp
def test_encode_valid_rsp(self):
m = pyipmi.msgs.fru.ReadFruDataRsp()
m.completion_code = 0
m.count = 5
m.data = array('B', '\x01\x02\x03\x04\x05')
data = encode_message(m)
self.assertEqual(data, '\x00\x05\x01\x02\x03\x04\x05')
示例12: test_clear_activation_lock_req
def test_clear_activation_lock_req(self):
m = pyipmi.msgs.picmg.SetFruActivationPolicyReq()
m.fru_id = 1
m.mask.activation_locked = 1
m.set.activation_locked = 0
data = encode_message(m)
self.assertEqual(data, "\x00\x01\x01\x00")
示例13: test_encode_valid_req_wo_data
def test_encode_valid_req_wo_data(self):
m = pyipmi.msgs.fru.WriteFruDataReq()
m.fru_id = 1
m.offset = 0x302
m.data = array('B')
data = encode_message(m)
self.assertEqual(data, '\x01\x02\x03')
示例14: test_encode_valid_req
def test_encode_valid_req(self):
m = pyipmi.msgs.fru.ReadFruDataReq()
m.fru_id = 1
m.offset = 0x302
m.count = 4
data = encode_message(m)
self.assertEqual(data, '\x01\x02\x03\x04')
示例15: test_clear_deactivation_lock_req
def test_clear_deactivation_lock_req():
m = pyipmi.msgs.picmg.SetFruActivationPolicyReq()
m.fru_id = 1
m.mask.deactivation_locked = 1
m.set.deactivation_locked = 0
data = encode_message(m)
eq_(data, b'\x00\x01\x02\x00')