This document describes the type parameter to the EmCan PORTYPE frame.
Type is a 16 bit integer that indicates the type of entity a EmCan port is. If the port is writable, the high bit (15) of type is set. If the port is readable, bit 14 is set. At least one of these two bits must be set since a port that is neither readable nor writable is pointless.
The low 14 bits of type are a ID specifying the general port type. All IDs not listed below are reserved and may be defined in the future. The port configuration data size, format, and meaning is dependent on the port type. Port configuration is set with the PORTCFG frame. Unless otherwise stated, a type does not support any configuration data. The defined type IDs and associated configuration data are:
The port data is simply the specified number of bits without any special handling.
The port can only have one of two states, and the bit size must be 1. The configuration data is a single byte:
NEG is 0 to indicate positive logic and 1 to indicate negative logic. The default is postive logic and means that a port value of 1 externally maps to a logic high, "on", etc, condition. A port value of 1 is meant to be "asserted", which may map differently to the output of the device depending on how it is connected and used withing the system. For example, if the port is a digital input with passive pullup and a pushbutton to ground, then it would be configured for negative logic since asserting the button drives the line low, which would otherwise be reported as a 0 port value.
Like the boolean type, except that successive events increment a counter. The bit size should be greater than 1, and is the total number of bits in the counter. The low bit of the count is the current port value, with 0 indicating unasserted and 1 asserted. A 1-bit counted boolean port type is therefore exactly the same as a boolean port type.
The configuration data is the same as for the boolean port type.
A counted boolean port could be appropriate, for example, for a pushbutton input. Even if a individual pushbutton press and release is not read separately, it can still be detected later by the count having advanced.