1# EDTT transport 2 3The EDTT transport only function is to deliver data from and to the EDTT tests 4into the devices under test. 5 6The transport behaves like a pipe/FIFO. 7 8How a given transport is implemented is fully up to the designer. It must only 9fulfill the expected interface in both sides: EDTT and the DUT. 10 11On the PC side the transport layer is implemented in Python. On the DUT side it 12is implemented in C. 13 14 15## EDTTT Python IF: 16 17A transport must be implemented as an importable python module and implement the 18following API: 19 20* __init__(args, trace_module): where: 21 * `<args>` are any command line arguments the EDTT has not been able 22 to parse. The transport may use this to 23 receive its own parameters. Note that the transport must be tolerant 24 to options which are meant for some other module. 25 * `<trace_module>` is the class which should be used for printing out 26 any possible message 27 28* connect() : Connect to the devices under test. 29* send(idx, message): Send the bytearray message to the device number 30 `<idx>` 31* recv(idx, number_bytes, timeout): Attempt to retrieve `<number_bytes>` 32 from the device number `<idx>`. If it cannot manage in `<timeout>` 33 milleseconds it shall just return an empty bytearray 34* wait(time): Block (wait) for `<time>` ms. Note that in case of simulated 35 devices, `<time>` should refer to simultaed time. For real devices, simply 36 use the host time. 37* close(): Disconnect from the devices under test 38* get_time(): Return the current time (simulated time for simulated devices) 39* n_devices : Number of devices it is connected to 40 41 42## EDTTT DUT IF: 43 44The embedded side of the transport must implement the following interface: 45 46### `bool edtt_start()` 47 48Initialize the transport to the EDTT 49 50### `bool edtt_stop()` 51 52Stop the transport to the EDTT. The app may not send 53any more traffic after this. 54 55### `int edtt_read(u8_t *ptr, size_t size, int flags)` 56 57Attempt to read size bytes thru the EDTT IF into the buffer `<*ptr>`. 58`<flags>` can be set to EDTTT_BLOCK or EDTTT_NONBLOCK 59 60If set to EDTTT_BLOCK it will block the calling thread until `<size>` 61bytes have been read or the interface has been closed. 62If set to EDTTT_NONBLOCK it returns as soon as there is no more data 63readily avaliable. 64 65Returns the amount of read bytes, or -1 on error 66 67### `int edtt_write(u8_t *ptr, size_t size, int flags)` 68 69Write `<size>` bytes from `<ptr>` toward the EDTTool 70 71`<flags>` can be set to EDTTT_BLOCK or EDTTT_NONBLOCK 72 73If set to EDTTT_BLOCK it will block the calling thread until `<size>` 74bytes have been written or the interface has been closed. 75If set to EDTTT_NONBLOCK it returns as soon as no more data could be 76"immediately" pushed out. Where, although immediately is ambigious, 77it must certainly include any action which would yield the thread. 78 79Returns the number of written bytes or -1 on error. 80 81There may be a delay between the time in which the write returns and the 82data is avalaible in the EDTT. But it is guaranteed that once this function 83return `<n>`, the first `<n>` bytes from `<ptr>` will be delivered to the EDTT 84before those of any subsequent call to this function. 85After the call returns, the caller is free to reuse the buffer pointed by 86`<ptr>` 87