MCPcopy Create free account
hub / github.com/ActiveState/code / put

Method put

recipes/Python/498085_Lego_Mindstorms_Bluetooth/recipe-498085.py:75–94  ·  view source on GitHub ↗

Send a raw message to NXT payload -- bytes to send box -- 1 to 10, which mail box on NXT to place message in

(self, payload, box=1)

Source from the content-addressed store, hash-verified

73 return payload, box
74
75 def put(self, payload, box=1):
76 '''
77 Send a raw message to NXT
78 payload -- bytes to send
79 box -- 1 to 10, which mail box on NXT to place message in
80 '''
81 # sz msg----> 0
82 # 0123456789 ... n
83 payload += chr(0)
84 pl_sz = len(payload)
85 sz = pl_sz + 4
86 header = struct.pack('h2sbb', sz, self.huh, box - 1, pl_sz)
87 out = struct.pack('6s%ds' % pl_sz, header, payload)
88 # print 'out', out
89 dat = out[2:6]
90 # for c in dat:
91 # print ord(c)
92 # print
93 # self.s.write('\x11\x00\x80\t\x00\r<0123456789>\x00')
94 self.s.write(out)
95
96 def __del__(self):
97 try:

Callers 15

workerFunction · 0.45
recipe-475160.pyFile · 0.45
producerFunction · 0.45
consumerFunction · 0.45
putMethod · 0.45
runMethod · 0.45
produceFunction · 0.45
runMethod · 0.45
execSQLFunction · 0.45
clientMethod · 0.45
goButton_clickedMethod · 0.45
processIncomingMethod · 0.45

Calls 2

packMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected