Skip to content

Commit eef42e6

Browse files
committed
Feat: Ported sendCOMM method
This follows PR nasa#295 from the original NASA repository
1 parent 11a5f35 commit eef42e6

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Python3/src/xpc/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,25 @@ def sendWYPT(self, op, points):
424424
else:
425425
buffer = struct.pack(("<4sxBB" + str(len(points)) + "f").encode(), b"WYPT", op, len(points), *points)
426426
self.sendUDP(buffer)
427+
428+
def sendCOMM(self, comm):
429+
'''Sets the specified datarefs to the specified values.
430+
Args:
431+
comm: Command to send.
432+
'''
433+
if comm == None:
434+
raise ValueError("comm must be non-empty.")
435+
436+
buffer = struct.pack(b"<4sx", b"COMM")
437+
if len(comm) == 0 or len(comm) > 255:
438+
raise ValueError("comm must be a non-empty string less than 256 characters.")
439+
440+
# Pack message
441+
fmt = "<B{0:d}s".format(len(comm))
442+
buffer += struct.pack(fmt.encode(), len(comm), comm.encode())
443+
444+
# Send
445+
self.sendUDP(buffer)
427446

428447

429448
class ViewType(object):

0 commit comments

Comments
 (0)