Тогда первый код выглядит так:
оффтопик
// L O O P
//--------------------------------------------------------------------------------------------
void loop() {
// SEND 15E START FB1
//--------------------------------------------------------------------------------------------
if (fbgr1 == false & fbgr0 == false) {
while ((currentMicrosR + 16000) > micros()) {
; // wait
}
currentMicrosR = micros();
RBus2.XNetsend1(FB_BROADCAST);
ifb++;
}
else {
while ((currentMicrosR + 16000) > micros()) {
; // wait
}
currentMicrosR = micros();
FB1();
}
Второй так
оффтопик
//--------------------------------------------------------------------------------------------
void FB0(){
// SEND 1DE GR 0
//--------------------------------------------------------------------------------------------
unsigned int sendStatus0[] = { G_B, 0xFC, 0x00 };
XNetclear0();
RBus2.XNetsend(sendStatus0, 3);
ReadData = true;
//--------------------------------------------------------------------------------------------
// SEND XOR GR 0
//--------------------------------------------------------------------------------------------
while ((currentMicrosR + 7980) > micros()) {
byte rxdata;
if (Serial2.available() > 0) {
rxdata = Serial2.read();
if (ReadData == true) { //Data are for own address?
XNetMsg0[0]++; //more news Loading
XNetMsg0[XNetMsg0[0]] = rxdata; //Enter
}
}
}
ReadData = false;
unsigned int sendxorgr0[] = { G_B, 0xFC, 0x00, XNetMsg0[1], XNetMsg0[2], XNetMsg0[3], XNetMsg0[4], XNetMsg0[5], XNetMsg0[6], XNetMsg0[7],XNetMsg0[8], XNetMsg0[9], XNetMsg0[10], 0x00};
RBus2.getXOR(sendxorgr0, 14);
if (XNetMsg0[XNetlength] != 0x00) {
fbgr0 = true;
}
else {
fbgr0 = false;
}
///------
for (int i = 1; i < FBlok; ++i) {
if (XNetMsg0[i] != NFBlokG0[i]) {
enableSegment0 = true;
NFBlokG0[i] = XNetMsg0[i]; // store the incoming byte into "inputs"
}
}
if (enableSegment0 == true) {
byte datasend[11];
// Массив: Групповой индекс (1 Byte) и статус блоков занятости(10 Byte)
datasend[0] = 0x00; // Групповой индекс для блоков с 1 по 10
datasend[1] = NFBlokG0[1];
datasend[2] = NFBlokG0[2];
datasend[3] = NFBlokG0[3];
datasend[4] = NFBlokG0[4];
datasend[5] = NFBlokG0[5];
datasend[6] = NFBlokG0[6];
datasend[7] = NFBlokG0[7];
datasend[8] = NFBlokG0[8];
datasend[9] = NFBlokG0[9];
datasend[10] = NFBlokG0[10];
EthSend (0x0F, 0x80, datasend, false, 0x02); //RMBUS_DATACHANED
enableSegment0 = false;
}
}
//--------------------------------------------------------------------------------------------
void FB1(){
// SEND 1DE GR 1
//--------------------------------------------------------------------------------------------
unsigned int sendStatus1[] = { G_B, 0xFC, 0x10 };
XNetclear1();
RBus2.XNetsend(sendStatus1, 3);
ReadData = true;
//--------------------------------------------------------------------------------------------
// SEND XOR GR 1
//--------------------------------------------------------------------------------------------
while ((currentMicrosR + 7980) > micros()) {
byte rxdata;
if (Serial2.available() > 0) {
rxdata = Serial2.read();
if (ReadData == true) { //Data are for own address?
XNetMsg1[0]++; //more news Loading
XNetMsg1[XNetMsg1[0]] = rxdata; //Enter
}
}
}
ReadData = false;
unsigned int sendxorgr1[] = { G_B, 0xFC, 0x10, XNetMsg1[1], XNetMsg1[2], XNetMsg1[3], XNetMsg1[4], XNetMsg1[5], XNetMsg1[6], XNetMsg1[7],XNetMsg1[8], XNetMsg1[9], XNetMsg1[10], 0x00};
RBus2.getXOR(sendxorgr1, 14);
if (XNetMsg1[XNetlength] != 0x00) {
fbgr1 = true;
}
else {
fbgr1 = false;
}
//---
for (int i = 1; i < FBlok; ++i) {
if (XNetMsg1[i] != NFBlokG1[i]) {
enableSegment1 = true;
NFBlokG1[i] = XNetMsg1[i]; // store the incoming byte into "inputs"
}
}
if (enableSegment1 == true) {
byte datasend[11];
// Массив: Групповой индекс (1 Byte) и статус блоков занятости(10 Byte)
datasend[0] = 0x01; // Групповой индекс для блоков с 1 по 10
datasend[1] = NFBlokG1[1];
datasend[2] = NFBlokG1[2];
datasend[3] = NFBlokG1[3];
datasend[4] = NFBlokG1[4];
datasend[5] = NFBlokG1[5];
datasend[6] = NFBlokG1[6];
datasend[7] = NFBlokG1[7];
datasend[8] = NFBlokG1[8];
datasend[9] = NFBlokG1[9];
datasend[10] = NFBlokG1[10];
EthSend (0x0F, 0x80, datasend, false, 0x02); //RMBUS_DATACHANED
enableSegment1 = false;
}
}
//--------------------------------------------------------------------------------------------
//Delete the last sent command
void XNetclear0(void) {
XNetMsg0[0] = 0x00; //Reset Message
XNetMsg0[1] = 0x00;
XNetMsg0[2] = 0x00;
XNetMsg0[3] = 0x00;
XNetMsg0[4] = 0x00;
XNetMsg0[5] = 0x00;
XNetMsg0[6] = 0x00;
XNetMsg0[7] = 0x00;
XNetMsg0[8] = 0x00;
XNetMsg0[9] = 0x00;
XNetMsg0[10] = 0x00;
}
//--------------------------------------------------------------------------------------------
//Delete the last sent command
void XNetclear1(void) {
XNetMsg1[0] = 0x00; //Reset Message
XNetMsg1[1] = 0x00;
XNetMsg1[2] = 0x00;
XNetMsg1[3] = 0x00;
XNetMsg1[4] = 0x00;
XNetMsg1[5] = 0x00;
XNetMsg1[6] = 0x00;
XNetMsg1[7] = 0x00;
XNetMsg1[8] = 0x00;
XNetMsg1[9] = 0x00;
XNetMsg1[10] = 0x00;
}
// END SKETCH
Цитата:
Сообщение от Alexmit
И забыли про переменные. Это от //------ void FB и до void setup()
|
В смысле?