22 the packet header are byte that identifies the instruction to be executed by the uC
25 - write to interface PIN, AER, SPI
26 - configure Interfaces
31for simplisity Commands use the Data32bitPacket
class
36class Data32bitHeader(enum.IntEnum) :
37 """Data32bitHeader are all command headers used in Data32bitPacket.
39 the description explains the function of the individual commands.
40 some commands ignore the value.
45 overwrite to enable __doc__ strings for enum elements
as second argument.
47 self = int.__new__(cls, value)
53 UC_CLOSE_CONNECTION = 255,
"""
54 this packet tells the PC buffer to close the connection to the uC
58 this packet is used to software reset the uC (clear the config), no harware reset
is performed
62 read all availiable output packets out of the output buffer, and clear the buffer afterwards
68 read only the last package, does not remove this package
from the ring buffer
73 return the current execution time to the output buffer
78 IN_READ_INSTRUCTIONS = 3, """
79 read all availiable input packets out of the input buffer that have not been processed
84 OUT_BUFFER_LAST_READ = 250, """
85 this packet is used to destinguish between an empty
and a full buffer
87 - value
is 1 so ignore
90 IN_FREE_INSTRUCTION_SPOTS = 5, """
91 this packet is used to request how many free spots there are
in the instruction ring buffer
94 OUT_FREE_INSTRUCTION_SPOTS = 101, """
95 this packet is used to report how many free spots there are
in the instruction ring buffer
98 IN_CONF_READ_ON_REQUEST = 6, """
99 legacy mode: turn off automatic sending of the output buffer
101 - value 1 for read on request (legacy)
102 - value 0
for continous read (default)
103 @todo move to sub config
107 set the execution time, if set to 0 recording
and exec are halted
108 if set to 1 (
or bigger) exec
and recoding will be started
from timestep 1 (
or bigger)
110 - value
is the time current to be set, maximum experiment time
is 2^32 usec
114 responce to the READ_TIME packet
116 - exec_time the current run time
117 - value the system_time (without run time offset)
122 sends an 32bit word on the SPI0 interface
124 - value is the 32bit to be send
129 sends an 32bit word on the SPI1 interface
131 - value is the 32bit to be send
135 sends an 32bit word on the SPI2 interface
137 - value is the 32bit to be send
141 responce to the IN_SPI0_32 packet
143 - exec_time the current run time
144 - value the 32bit word that was read on the SPI
148 responce to the IN_SPI1_32 packet
150 - exec_time the current run time
151 - value the 32bit word that was read on the SPI
155 responce to the IN_SPI2_32 packet
157 - exec_time the current run time
158 - value the 32bit word that was read on the SPI
161 IN_ASYNC_TO_CHIP0 = 30, """
162 sends an 0-32bit word on the ASYNC_TO_CHIP0 interface
164 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
167 IN_ASYNC_TO_CHIP1 = 31 , """
168 sends an 0-32bit word on the ASYNC_TO_CHIP1 interface
170 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
173 IN_ASYNC_TO_CHIP2 = 32, """
174 sends an 0-32bit word on the ASYNC_TO_CHIP2 interface
176 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
179 IN_ASYNC_TO_CHIP3 = 33, """
180 sends an 0-32bit word on the ASYNC_TO_CHIP3 interface
182 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
185 IN_ASYNC_TO_CHIP4 = 34, """
186 sends an 0-32bit word on the ASYNC_TO_CHIP4 interface
188 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
191 IN_ASYNC_TO_CHIP5 = 35, """
192 sends an 0-32bit word on the ASYNC_TO_CHIP5 interface
194 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
197 IN_ASYNC_TO_CHIP6 = 36, """
198 sends an 0-32bit word on the ASYNC_TO_CHIP6 interface
200 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
203 IN_ASYNC_TO_CHIP7 = 37, """
204 sends an 0-32bit word on the ASYNC_TO_CHIP7 interface
206 - value is the word to be send,
if the width
is configured to >32 the MS bits are ignored
210 OUT_ASYNC_FROM_CHIP0 = 130, """
211 a event was reseved on ASYNC_FROM_CHIP0
213 - exec_time the current run time
214 - value the 0-32bit word that was read on the AER
217 OUT_ASYNC_FROM_CHIP1 = 131, """
218 a event was reseved on ASYNC_FROM_CHIP1
220 - exec_time the current run time
221 - value the 0-32bit word that was read on the AER
224 OUT_ASYNC_FROM_CHIP2 = 132, """
225 a event was reseved on ASYNC_FROM_CHIP2
227 - exec_time the current run time
228 - value the 0-32bit word that was read on the AER
231 OUT_ASYNC_FROM_CHIP3 = 133, """
232 a event was reseved on ASYNC_FROM_CHIP3
234 - exec_time the current run time
235 - value the 0-32bit word that was read on the AER
238 OUT_ASYNC_FROM_CHIP4 = 134, """
239 a event was reseved on ASYNC_FROM_CHIP4
241 - exec_time the current run time
242 - value the 0-32bit word that was read on the AER
245 OUT_ASYNC_FROM_CHIP5 = 135, """
246 a event was reseved on ASYNC_FROM_CHIP5
248 - exec_time the current run time
249 - value the 0-32bit word that was read on the AER
252 OUT_ASYNC_FROM_CHIP6 = 136, """
253 a event was reseved on ASYNC_FROM_CHIP6
255 - exec_time the current run time
256 - value the 0-32bit word that was read on the AER
259 OUT_ASYNC_FROM_CHIP7 = 137, """
260 a event was reseved on ASYNC_FROM_CHIP7
262 - exec_time the current run time
263 - value the 0-32bit word that was read on the AER
266 IN_MAPPER_KEY = 190, """
267 in mapper key switches into sequence transmission mode,
268 the next packet
is considered the key all subsequent packages
269 are considdered values until IN_MAPPER_END.
272 IN_MAPPER_END = 191, """
273 In mapper end switches back to normal packet exec mode.
277class PinHeader(enum.IntEnum) :
278 """PinHeader are all command headers used in PinPacket.
280 the description explains the function of the individual commands.
285 overwrite to enable __doc__ strings for enum elements
as second argument.
287 self = int.__new__(cls, value)
294 send a modify output pin command
296 - pin is the pin number
297 - value
is 0
or 1
for low
or high
300 IN_PIN_READ = 11, """
301 send a read input pin command
303 - pin is the pin number
307 OUT_PIN_LOW = 110, """
308 After a input pin change this records the change
310 - exec_time the time the change occured
312 - value the new state
315 OUT_PIN_HIGH = 111, """
316 After a input pin change this records the change
318 - exec_time the time the change occured
320 - value the new state
324class DataI2CHeader(enum.IntEnum) :
325 """DataI2CHeader are all command headers used in DataI2CPacket.
327 the description explains the function of the individual commands.
332 overwrite to enable __doc__ strings for enum elements
as second argument.
334 self = int.__new__(cls, value)
341 sends an 8 or 16 bit word
or recives a specified number of bytes on the I2C interface
343 - device_address
is the 7bit (MS) address of the device
and the LSB indicates Read(1)/Write(0) following the i2c standard
344 - register_address
is the 8bit register address
345 - value_ms
is the MS 8bit to be send
346 - value_ls
is the LS 8bit to be send
or the number of bytes to read
350 sends an 8 or 16 bit word
or recives a specified number of bytes on the I2C interface
352 - device_address
is the 7bit (MS) address of the device
and the LSB indicates Read(1)/Write(0) following the i2c standard
353 - register_address
is the 8bit register address
354 - value_ms
is the MS 8bit to be send
355 - value_ls
is the LS 8bit to be send
or the number of bytes to read
359 sends an 8 or 16 bit word
or recives a specified number of bytes on the I2C interface
361 - device_address
is the 7bit (MS) address of the device
and the LSB indicates Read(1)/Write(0) following the i2c standard
362 - register_address
is the 8bit register address
363 - value_ms
is the MS 8bit to be send
364 - value_ls
is the LS 8bit to be send
or the number of bytes to read
368 responce to the IN_SPI0 packet
370 - exec_time the current run time
371 - value the 8bit word that was read on the SPI
375 responce to the IN_SPI1 packet
377 - exec_time the current run time
378 - value the 8bit word that was read on the SPI
382 responce to the IN_SPI2 packet
384 - exec_time the current run time
385 - value the 8bit word that was read on the SPI
389class ConfigMainHeader(enum.IntEnum) :
391 ConfigMainHeader are all command headers used in ConfigPacket
in conjunction
with ConfigSubHeader.
393 The description explains the function of the individual commands.
394 The main header specifies the interface to be configured
and the sub header the property
395 which should be configured.
400 overwrite to enable __doc__ strings for enum elements
as second argument.
402 self = int.__new__(cls, value)
409 IN_CONF_READ_ON_REQUEST = 6,
"""
410 legacy mode: turn off automatic sending of the output buffer
411 - value 1 for read on request (legacy)
412 - value 0
for continous read (default)
415 IN_CONF_PIN = 50, """
416 sets the pin configuration
418 - config/sub header is the config state to be applied the pin
419 - value
is the pin id
422 IN_CONF_SPI0 = 60, """
423 sets the spi0 configuration
425 - config/sub header is the config state to be applied the spi
426 - value
is used according to the config sub header
429 IN_CONF_SPI1 = 61, """
430 sets the spi1 configuration
432 - config/sub header is the config state to be applied the spi
433 - value
is used according to the config sub header
436 IN_CONF_SPI2 = 62, """
437 sets the spi2 configuration
439 - config/sub header is the config state to be applied the spi
440 - value
is used according to the config sub header
443 IN_CONF_I2C0 = 65, """
444 sets the i2c0 configuration
446 - config/sub header is the config state to be applied the spi
447 - value
is used according to the config sub header
450 IN_CONF_I2C1 = 66, """
451 sets the i2c1 configuration
453 - config/sub header is the config state to be applied the spi
454 - value
is used according to the config sub header
457 IN_CONF_I2C2 = 67, """
458 sets the i2c2 configuration
460 - config/sub header is the config state to be applied the spi
461 - value
is used according to the config sub header
464 IN_CONF_ASYNC_TO_CHIP0 = 70, """
465 sets the ASYNC_TO_CHIP0 configuration
467 - config/sub header is the config state to be applied the aer interface
468 - value
is used according to the config sub header
471 IN_CONF_ASYNC_TO_CHIP1 = 71, """
472 sets the ASYNC_TO_CHIP1 configuration
474 - config/sub header is the config state to be applied the aer interface
475 - value
is used according to the config sub header
478 IN_CONF_ASYNC_TO_CHIP2 = 72, """
479 sets the ASYNC_TO_CHIP2 configuration
481 - config/sub header is the config state to be applied the aer interface
482 - value
is used according to the config sub header
485 IN_CONF_ASYNC_TO_CHIP3 = 73, """
486 sets the ASYNC_TO_CHIP3 configuration
488 - config/sub header is the config state to be applied the aer interface
489 - value
is used according to the config sub header
492 IN_CONF_ASYNC_TO_CHIP4 = 74, """
493 sets the ASYNC_TO_CHIP4 configuration
495 - config/sub header is the config state to be applied the aer interface
496 - value
is used according to the config sub header
499 IN_CONF_ASYNC_TO_CHIP5 = 75, """
500 sets the ASYNC_TO_CHIP5 configuration
502 - config/sub header is the config state to be applied the aer interface
503 - value
is used according to the config sub header
506 IN_CONF_ASYNC_TO_CHIP6 = 76, """
507 sets the ASYNC_TO_CHIP6 configuration
509 - config/sub header is the config state to be applied the aer interface
510 - value
is used according to the config sub header
513 IN_CONF_ASYNC_TO_CHIP7 = 77, """
514 sets the ASYNC_TO_CHIP7 configuration
516 - config/sub header is the config state to be applied the aer interface
517 - value
is used according to the config sub header
520 IN_CONF_ASYNC_FROM_CHIP0 = 80, """
521 sets the ASYNC_FROM_CHIP0 configuration
523 - config/sub header is the config state to be applied the aer interface
524 - value
is used according to the config sub header
527 IN_CONF_ASYNC_FROM_CHIP1 = 81, """
528 sets the ASYNC_FROM_CHIP1 configuration
530 - config/sub header is the config state to be applied the aer interface
531 - value
is used according to the config sub header
534 IN_CONF_ASYNC_FROM_CHIP2 = 82, """
535 sets the ASYNC_FROM_CHIP2 configuration
537 - config/sub header is the config state to be applied the aer interface
538 - value
is used according to the config sub header
541 IN_CONF_ASYNC_FROM_CHIP3 = 83, """
542 sets the ASYNC_FROM_CHIP3 configuration
544 - config/sub header is the config state to be applied the aer interface
545 - value
is used according to the config sub header
548 IN_CONF_ASYNC_FROM_CHIP4 = 84, """
549 sets the ASYNC_FROM_CHIP4 configuration
551 - config/sub header is the config state to be applied the aer interface
552 - value
is used according to the config sub header
555 IN_CONF_ASYNC_FROM_CHIP5 = 85, """
556 sets the ASYNC_FROM_CHIP5 configuration
558 - config/sub header is the config state to be applied the aer interface
559 - value
is used according to the config sub header
562 IN_CONF_ASYNC_FROM_CHIP6 = 86, """
563 sets the ASYNC_FROM_CHIP6 configuration
565 - config/sub header is the config state to be applied the aer interface
566 - value
is used according to the config sub header
569 IN_CONF_ASYNC_FROM_CHIP7 = 87, """
570 sets the ASYNC_FROM_CHIP7 configuration
572 - config/sub header is the config state to be applied the aer interface
573 - value
is used according to the config sub header
578@TODO some of them use other formates but did
not had time to sort them yet
581class ErrorHeader(enum.IntEnum) :
583 ErrorHeader are all command headers used in ErrorPacket.
585 Errors are issued by the uC to tell the user what went wrong.
586 The description explains the meaning of the individual errors.
588 the causing errors can be found
in org_header
and org_sub_header
589 the causeing valuse
is stored
in value,
if a value does
not make sense
590 for that error
class it is the current timestamp of the uC.
595 overwrite to enable __doc__ strings for enum elements
as second argument.
597 self = int.__new__(cls, value)
604 Unspecified error. Something went wrong, and the microcontroller doesn
't know why.
607 OUT_ERROR_PIN_ALREADY_INUSE = 201, """
608 The pin or interface you’re trying to activate
is already
in use
or was previously configured. To reset,
609 call close_connection() on the uC_api, then create a new uC_api instance to reconnect after the microcontroller resets.
612 OUT_ERROR_PIN_NOT_CONFIGURED = 202, """
613 The pin you’re attempting to use isn’t configured. Please initialize it first by calling pin[X].activate(<options>)
614 or sending the necessary configuration packets.
617 OUT_ERROR_INPUT_FULL = 203, """
618 The timed instruction buffer is full, so new instructions cannot be stored
and will be discarded.
621 OUT_ERROR_OUTPUT_FULL = 204, """
622 The output buffer is full, causing packets to be dropped. The value shown
is the count of dropped packets.
625 OUT_ERROR_INTERFACE_ALREADY_ACTIVE = 205, """
626 The interface you’re trying to activate is already configured
and active. To reconfigure, call close_connection()
627 on the uC_api, then create a new uC_api instance to reconnect after the microcontroller resets.
630 OUT_ERROR_UNKNOWN_INSTRUCTION = 206, """
631 The instruction header sent is unrecognized
or invalid
for the microcontroller,
632 possibly due to an API
and firmware version mismatch.
635 OUT_ERROR_INTERFACE_NOT_ACTIVE = 207, """
636 The interface you're trying to use is not yet configured. Please initialize it by calling
637 <interface>[X].activate(<options>) or sending the necessary configuration packets.
640 OUT_ERROR_UNKNOWN_CONFIGURATION = 208, """
641 The configuration header sent is unrecognized
or invalid
for the microcontroller,
642 possibly due to an API
and firmware version mismatch.
645 OUT_ERROR_ASYNC_HS_TIMEOUT = 209, """
646 The asynchronous sending interface has not received an acknowledgment
for some time
and
647 has reset the request. Please restart
or reset the Device Under Test (DuT).
650 OUT_ERROR_PERIPHERAL_INTERFACE_NOT_READY = 210, """
651 This error occurs when a peripheral interface is not ready, such
as when the I2C
for the MCP23017
is not available.
654 OUT_ERROR_CONFIGURATION_OUT_OF_BOUNDS = 211, """
655 The configuration ID sent exceeds the available microcontroller resources. Please check the ID, as it
is invalid.
658 OUT_ERROR_DATA_OUT_OF_BOUNDS = 212, """
659 The data sent exceeds the configured bit/byte word length of the interface. Please check the data, as it
is invalid.
662 OUT_WARNING_DATA_COLLECTION_SQUEUED = 213, """
663 Data collection is taking too long due to excessive requests, preventing the microcontroller
from transmitting data to the PC.
664 Consequently, the uC will temporarily pause data collection to send approximately 10 packets to the PC before resuming data collection.
665 This warning will be issued only once.
668 OUT_ALIGN_SUCCESS_VERSION = 253, """
669 This response to the alignment request confirms the connection with the microcontroller
and includes the
670 firmware version to verify the correct version
is running. The format
is as follows (uses the error_package struct):
671 - org_header: major version (8-bit)
672 - sub_header: minor version (8-bit)
673 - value: patch version (32-bit)
679to make sure that all headers are unique,
and to access all of them independen of thier
class
688class ConfigSubHeader(enum.IntEnum):
690 ConfigSubHeader are all command headers used in ConfigPacket
in conjunction
with ConfigMainHeader.
692 The description explains the function of the individual commands.
693 The main header specifies the interface to be configured
and the sub header the property
694 which should be configured.
699 overwrite to enable __doc__ strings for enum elements
as second argument.
701 self = int.__new__(cls, value)
707 CONF_ACTIVE = 60,
"""
708 set an interface to active, after activation the pins/width cant be changed anymore
709 works for spi
and aer, activation will fail
if pins are already used
for other interfaces
710 @TODO deactivation
not implemented yet sould be new header
for compatebility
715 CONF_OUTPUT = 61, """
716 set a pin to output to be able to write on it
722 set a pin to input, it registers an interupt service
723 to record all incomming changes
729 sets the Req pin for the given AER interface
735 sets the Ack pin for the given AER interface
741 sets the bit width of the given AER interface
743 - value is width 0-32
746 CONF_REQ_DELAY = 73, """
747 set the delay on the request line
749 - value the delay in multiple of 20ns
752 CONF_BYTE_ORDER = 74, """
754 - value LSFIRST = 0 and MSFIRST = 1 - default
is 0
757 CONF_SPEED_CLASS = 75, """
758 interface speed class se interface doc
763 - value type id (see interface doc) - default is 0
766 CONF_NONE = 255, "indication of no sub category"
768 CONF_CHANNEL0 = 0,
"setting the pin for Async data channel"
769 CONF_CHANNEL1 = 1,
"setting the pin for Async data channel"
770 CONF_CHANNEL2 = 2,
"setting the pin for Async data channel"
771 CONF_CHANNEL3 = 3,
"setting the pin for Async data channel"
772 CONF_CHANNEL4 = 4,
"setting the pin for Async data channel"
773 CONF_CHANNEL5 = 5,
"setting the pin for Async data channel"
774 CONF_CHANNEL6 = 6,
"setting the pin for Async data channel"
775 CONF_CHANNEL7 = 7,
"setting the pin for Async data channel"
776 CONF_CHANNEL8 = 8,
"setting the pin for Async data channel"
777 CONF_CHANNEL9 = 9,
"setting the pin for Async data channel"
778 CONF_CHANNEL10 = 10,
"setting the pin for Async data channel"
779 CONF_CHANNEL11 = 11,
"setting the pin for Async data channel"
780 CONF_CHANNEL12 = 12,
"setting the pin for Async data channel"
781 CONF_CHANNEL13 = 13,
"setting the pin for Async data channel"
782 CONF_CHANNEL14 = 14,
"setting the pin for Async data channel"
783 CONF_CHANNEL15 = 15,
"setting the pin for Async data channel"
784 CONF_CHANNEL16 = 16,
"setting the pin for Async data channel"
785 CONF_CHANNEL17 = 17,
"setting the pin for Async data channel"
786 CONF_CHANNEL18 = 18,
"setting the pin for Async data channel"
787 CONF_CHANNEL19 = 19,
"setting the pin for Async data channel"
788 CONF_CHANNEL20 = 20,
"setting the pin for Async data channel"
789 CONF_CHANNEL21 = 21,
"setting the pin for Async data channel"
790 CONF_CHANNEL22 = 22,
"setting the pin for Async data channel"
791 CONF_CHANNEL23 = 23,
"setting the pin for Async data channel"
792 CONF_CHANNEL24 = 24,
"setting the pin for Async data channel"
793 CONF_CHANNEL25 = 25,
"setting the pin for Async data channel"
794 CONF_CHANNEL26 = 26,
"setting the pin for Async data channel"
795 CONF_CHANNEL27 = 27,
"setting the pin for Async data channel"
796 CONF_CHANNEL28 = 28,
"setting the pin for Async data channel"
797 CONF_CHANNEL29 = 29,
"setting the pin for Async data channel"
798 CONF_CHANNEL30 = 30,
"setting the pin for Async data channel"
799 CONF_CHANNEL31 = 31,
"setting the pin for Async data channel"
803the 2 packets are used to align the communication between the PC and the uC
805ALIGN_BYTEARRAY = b
'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfd\x00\x00\x00\x00\x00\x00\x00\x00'
808list of headers that should be logged on arrival
809errors are logged by default
811LOGGING_WARNING_LIST = [Data32bitHeader.IN_RESET]
812LOGGING_INFO_LIST = []
816 add a header to the list of logged warnings
818 LOGGING_WARNING_LIST.append(header)
822 remove a header from the list of logged warnings
824 LOGGING_WARNING_LIST.remove(header)
828 add a header to the list of logged info
830 LOGGING_INFO_LIST.append(header)
834 remove a header from the list of logged info
836 LOGGING_INFO_LIST.remove(header)
ConfigMainHeader are all command headers used in ConfigPacket in conjunction with ConfigSubHeader.
def __new__(cls, value, doc=None)
overwrite to enable doc strings for enum elements as second argument.