Fakes API
UART and Pin fakes
Fakes of several MicroPython classes which are not available in UNIX
- exception fakes.machine.MachineError[source]
Bases:
Exception
Base class for exceptions in this module.
- class fakes.machine.Pin(pin: int, mode: int)[source]
Bases:
object
Fake Micropython Pin class
See https://docs.micropython.org/en/latest/library/machine.Pin.html
- class fakes.machine.UART(uart_id: int, baudrate: int = 9600, bits: int = 8, parity: Optional[int] = None, stop: int = 1, tx: int = 1, rx: int = 2, timeout: int = 0)[source]
Bases:
object
Fake Micropython UART class
See https://docs.micropython.org/en/latest/library/machine.UART.html
- _configure_logger() Logger [source]
Create and configure a logger
- Returns
Configured logger
- Return type
- _serve(sock: <module 'socket' from '/home/docs/.asdf/installs/python/3.9.17/lib/python3.9/socket.py'>, send_queue: ~queue.Queue, receive_queue: ~queue.Queue, lock: int, logger: ~logging.Logger) None [source]
Internal socket server function
- Parameters
sock (socket) – The socket
send_queue (Queue) – The send queue
receive_queue (Queue) – The receive queue
lock (int) – The lock flag
logger (logging.Logger) – The logger
- any() int [source]
Return number of characters available.
Mock does not return the actual number of characters but the elements in the receive queue. Which is usually “0” or “1”
- Returns
Number of characters available
- Return type
- property is_server: bool
Determines if this object acts as server aka UART host.
- Returns
True if server, False otherwise.
- Return type
- no_socket_server_exists(host: str, port: int, timeout: Optional[float] = 1.0) bool [source]
Determines if no socket server exists.
- readinto(buf: bytes, nbytes: Optional[int] = None) Union[None, bytes] [source]
Read bytes into the buffer.
If nbytes is specified then read at most that many bytes. Otherwise, read at most len(buf) bytes
- readline() Union[None, str] [source]
Read a line, ending in a newline character
- Returns
The line read, None on timeout.
- Return type
Union[None, str]
- property serving: bool
Get the server status.
- Returns
Flag whether socket server is running or not.
- Return type