Hello again,
as promised[1] a short documentation of the protocol I've used:
PC => DSKY
A message from the PC to the external DSKY consists of three bytes that represent
a) the channel number (010, 011 & 013)
b) the channel value (bit-flags, depending on the channel, for further details
Table of IO Channels)
This C-structure shows this:
PHP:
#pragma pack(1)
typedef struct{
UINT8 channel; // [010|011|013]
UINT16 value; // channel data
} message_t;
Note, that this message will be transmitted via the UART in "TCP/IP
network byte order". This means that the data format for the 'value' is
big-endian
I am not sure by now, why I choose that endianess, but I think I had in mind to connect my external DSKY directly to the
virtual AGC project, which uses network sockets to communicate.
DSKY => PC
For whatever reasons I choose a different approach for the other direction (DSKY to PC).
As only the keyboard creates events/messages, one single channel would fulfill the task, but as the real Hardware handled the PRO key different than all the other keys, I "invented" another message style for the "return trip"[2]
A message from the external DSKY to the PC consists of four bytes that represent
a) Kind (either '
k' for (K)eycode, or '
b' for Input Channel (B)it.
b) Three bytes of data, depending on the type of course:
For
'k' messages, only the first byte contains the keycode value, the following two bytes will always be zero. The 'keycode' values are like the
Input Channel 015 values found at Virtual AGC documentation.
For
'b' messages, the first data byte contains the channel value (only 032, ass we only message the PRO-Key state); the second data byte contains the bit-number (here 14) to be manipulated; the third data byte contains either a one (1) or a zero (0) to either set or clear that bit.
A C-structure showing this:
PHP:
#pragma pack(1)
typedef struct {
UINT8 type; // ['k'|'b']
union {
struct {
UINT8 channel; // 032
UINT8 bit; // currently only 14
UINT8 value; // [0|1]
} k;
struct {
UINT8 keycode; // AGC Keycode (Input channel 015)
UINT16 spare; // all zero
} b;
} data;
} message_t;
Note, that due to the fact that the only multi-byte data is 'spare' it does not matter what endianess is used here.
For all who are not familiar with octal number representation, do yourself a favor and get used to it if you are planning to build or work with a DSKY.
[1] ...kind of
[2] this might not be the most clever solution I think, but it worked back then when I build this thing and as it did work I felt no more pressure to change that