Tree: ports

From RFID Wiki

[edit] Ports and Port Types

All RFID communication in the RFID Guardian uses an abstraction, port. A port is a bidirectional endpoint for communication, comparable with a Berkeley socket.


Where a port differs from a socket is in the type of its data stream. RFID communication sends not only bytes, but also frame markers (SOF, EOF), and also isolated markers that don't delineate a frame, e.g. to mark transition to the next slot in 16-slot inventory (15693). Besides, some RFID protocols need to send or receive data that is not a whole number of bytes. For the RFID Guardian, we also need a way to communicate to the device that from a certain bit onwards, it should send garbling data in stead of bytes. The mrg_symbol_stream_t is a data type that can fullfil these demands: it has a byte and a parallel marker in each entry.


This is C, and that makes implementation of a uniform API to ports nontrivial: we want to do port_write(port, data), and this port_write function can be implemented only in one place. However, each port type must have a port_write function. We chose a solution with a vtable. Individual port types need to fill a vtable with pointers to their implementation functions. The library then dispatches through the vtable: if it is called as port_write(port, data), then it invokes port->vtable.port_write(port, data).


Depends on: