Pad data to 8 bytes, remove * imports
This commit is contained in:
parent
db9fb0e32d
commit
43b558d8ac
1 changed files with 18 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from itertools import compress
|
||||
from struct import *
|
||||
from struct import Struct, calcsize, pack, unpack
|
||||
from time import sleep
|
||||
|
||||
import sys
|
||||
|
|
@ -115,6 +115,11 @@ class StenoPacket(object):
|
|||
if sequence_number is None:
|
||||
sequence_number = StenoPacket.sequence_number
|
||||
StenoPacket._increment_sequence_number()
|
||||
if data is not None:
|
||||
# Data is padded to 8 bytes
|
||||
remainder = len(data) % 8
|
||||
if remainder:
|
||||
data += b'\x00' * (8 - remainder)
|
||||
if data_length is None:
|
||||
data_length = len(data)
|
||||
self.sequence_number = sequence_number
|
||||
|
|
@ -166,9 +171,8 @@ class StenoPacket(object):
|
|||
return packet
|
||||
|
||||
@staticmethod
|
||||
def make_open_request(file_name=b'REALTIME.000\x00\x00\x00\x00', disk_id=b'A'):
|
||||
def make_open_request(file_name=b'REALTIME.000', disk_id=b'A'):
|
||||
"""Request to open a file on the writer, defaults to the realtime file."""
|
||||
# Concern: realtime file seems to need 4 null bytes. Maybe to round up to 0x10?
|
||||
return StenoPacket(
|
||||
packet_id=StenoPacket.ID_OPEN,
|
||||
p1=ord(disk_id) if disk_id else 0, # Omitting p1 may use the default drive.
|
||||
|
|
@ -222,7 +226,17 @@ class AbstractStenographMachine(object):
|
|||
raise NotImplementedError('send_receive() is not implemented')
|
||||
|
||||
if sys.platform.startswith('win32'):
|
||||
from ctypes import *
|
||||
from ctypes import (
|
||||
Structure,
|
||||
POINTER,
|
||||
c_ulonglong,
|
||||
windll,
|
||||
create_string_buffer,
|
||||
sizeof,
|
||||
byref,
|
||||
pointer,
|
||||
c_char,
|
||||
)
|
||||
from ctypes.wintypes import DWORD, HANDLE, BYTE
|
||||
import uuid
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue