hello,
I actually have to read a row of 300 bytes from a home made scanner.
I send a request to send it, and then I get the 300 bytes sent.
Of course I have to store it somewhere.
is that possible in one go?
or is that limited?
I read somewhere that there is a maximum of 32, but i am not really sure what that actually means.
thank you.
Should be no problem getting 300 bytes in one go, unless there is a limitation in the device you are using. Is this a raspberry pi or something similar? What is the format of the data in the 300 bytes? You might have to unpack the bytes to get in a format you can use.
the data is comming from a atmega32,
and i wil received it in a raspberry pico.
if it is possible i want to store it binair, just "1" and "0".
There is no such thing as binary in python. You can get a str which is the binary representation of an int, but that is the characters "0" and "1", not one bit values.
Will the data be 300 0/1 values or 300 bytes, each having 8 bits of 0/1 data?
Yeah, there might be a solution for it.
Quote:Will the data be 300 0/1 values or 300 bytes, each having 8 bits of 0/1 data?
that last one, 300 bytes with 8 bits in it.
from machine import UART
def get_scanner_row(uart: UART) -> bytearray:
"""
Send request to scanner, receive 300 bytes and return them.
"""
response_buffer = bytearray(300)
# https://docs.micropython.org/en/latest/library/machine.UART.html#machine.UART.write
uart.write(b"your command to get the resopnse of 300 bytes\r\n")
# https://docs.micropython.org/en/latest/library/machine.UART.html#machine.UART.readinto
# blocking call until response_buffer is full
uart.readinto(response_buffer)
return response_buffer
# https://docs.micropython.org/en/latest/library/machine.UART.html#class-uart-duplex-serial-communication-bus
uart = UART(1, 9600)
# blocks until 300 bytes are received
# the response is a bytearray
response = get_scanner_row(uart)
# printing the data byte for byte
# in binary form
for index, value in enumerate(response):
print(f"Byte {index:>3d}: {value:0b}")
Code is not tested. Just as a starting point, how to send data via micropython.
that's clearly code written by an expert.
I'll see if I can figure that out
thanks for your help.