Skip to content

Commit 20a4b3c

Browse files
authored
Merge pull request #62 from DownD/Allow-to-send-specific-byte-array
Allow the user to send a user specified bytearray
2 parents 6958f93 + d83c31d commit 20a4b3c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pySerialTransfer/pySerialTransfer.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,22 @@ def tx_obj(self, val, start_pos=0, byte_format='', val_type_override=''):
284284
val_bytes = struct.pack(self.byte_format + format_str, bytes(str(val), "utf-8"))
285285
else:
286286
val_bytes = struct.pack(self.byte_format + format_str, val)
287+
288+
return self.tx_struct_obj(val_bytes, start_pos)
289+
290+
def tx_struct_obj(self, val_bytes, start_pos=0):
291+
'''
292+
Description:
293+
-----------
294+
Insert a byte array into the TX buffer starting at the
295+
specified index
296+
297+
:param val_bytes: bytearray - value to be inserted into TX buffer
298+
:param start_pos: int - index of TX buffer where the first byte
299+
of the value is to be stored in
300+
:return: int - index of the last byte of the value in the TX buffer + 1,
301+
None if operation failed
302+
'''
287303

288304
for index in range(len(val_bytes)):
289305
self.txBuff[index + start_pos] = val_bytes[index]

0 commit comments

Comments
 (0)