Since byte has 8 bits (0-7). Am I right then, that to send 10th bit, do I need to write it like this?
bitWrite(doPC[1], 2, !digitalRead(33));
Does that mean, that switch group equals byte in brackets? [ ]
While i think this is generally correct, there's a bit more to it, see below:
If yes, then in Maszyna UART xml doc "Numer bajtu struktury" should work for inputs. But for outputs, column "Nr bajtu transmisji danych" works just fine. (atleast for me) Is this right? I find it rather confusing (maybe because i dont understand Polish much). I was looking into column "Nr B danych" and was confused why 0 was used here. bitWrite(doPC[0], 7, !digitalRead(41)); // przycisk CA/SHP
"Numer bajtu danych" indicates the byte of the data package sent from the simulator to the external device. The first four bytes of this package hold fixed header,
EFEFEFEF, which is why "numer bajtu struktury" i.e. the byte id for each piece of actual data is shifted by 4 (the 1st byte of data is the 5th byte of the package, and so on)
The xls table describes (fixed) layout of data which the simulator sends to the external device. What you send back to the simulator is left largely up to you, as long as you inform the simulator how to interpret the data, using the eu07_input-uart.ini
but there's one caveat -- the first four bytes in the package you sent also need to contain
EFEFEFEFThis is probably the source of your problem #1, in your code you set the content of first byte to a different value by setting one of its bits. As a result, the header is no longer EFEFEFEF and the simulator doesn't accept your data. So i'm guessing the data which in the .ini file is described as "bit 1" should be recorded as
doPC[4], 0 and so on. However this is just a guess, as i have no personal experience with Arduino.
EDIT: for a better idea of what's going on, you can add string
uartdebug yes
to the file
eu07.ini