Fixing issues after testing

This commit is contained in:
Ryan Summers 2021-07-26 13:47:03 +02:00
parent 11d279a1b6
commit 1c66310b6d
3 changed files with 6 additions and 8 deletions

View File

@ -32,7 +32,7 @@ def parse_packet(buf):
""" Attempt to parse packets from the received buffer. """
# Attempt to parse a block from the buffer.
if len(buf) < struct.calcsize(HEADER_FORMAT):
return None
return []
# Parse out the packet header
magic, format_id, batch_size, sequence_number = struct.unpack_from(HEADER_FORMAT, buf)
@ -40,14 +40,14 @@ def parse_packet(buf):
if magic != MAGIC_HEADER:
logging.warning('Encountered bad magic header: %s', hex(magic))
return None
return []
if format_id not in FORMAT:
raise Exception(f'Unknown format specifier: {format_id}')
frame_format = FORMAT[format_id](batch_size)
batch_count = len(buf) / struct.calcsize(frame_format)
batch_count = int(len(buf) / struct.calcsize(frame_format))
packets = []
for offset in range(batch_count):
@ -135,9 +135,7 @@ def main():
# Handle any received packets.
total_bytes += len(data)
packet = parse_packet(data)
if packet:
for packet in parse_packet(data):
# Handle any dropped packets.
drop_count += sequence_delta(last_index, packet.index)
last_index = packet.index

View File

@ -315,7 +315,7 @@ const APP: () = {
.chain(dac_samples.iter())
.zip(buf.chunks_exact_mut(N))
{
assert_eq!(core::mem::size_of_val(data), N);
assert_eq!(core::mem::size_of_val(*data), N);
let data = unsafe {
core::slice::from_raw_parts(
data.as_ptr() as *const u8,

View File

@ -403,7 +403,7 @@ const APP: () = {
.chain(dac_samples.iter())
.zip(buf.chunks_exact_mut(N))
{
assert_eq!(core::mem::size_of_val(data), N);
assert_eq!(core::mem::size_of_val(*data), N);
let data = unsafe {
core::slice::from_raw_parts(
data.as_ptr() as *const u8,