// send data: ID = 0x100, Standard CAN Frame, Data length = 8 bytes, 'data' = array of data bytes to send //byte sndStat = CAN0.sendMsgBuf(0x100, 0, 8, data); Serial.println("For tesing init remote ports"); /* for (String v: _Slave_Ports) { Serial.print("Port: "); Serial.println(v); // for (auto i: v) { // do something with i //} } const char * const _Protocol; int _Slave_ID; int PortTypes; //0xFF = 1111 1111 { PWM, .....} = 0x80 // byte has_Address; int Address ; // byte has_Local_Port; int LocalPort; int Exp_state; int Exp_state_ttl; // 0x00 = odswiezyc */ for (auto element: _Slave_Ports) { Serial.print(" Prot:"); Serial.print(element._Protocol); Serial.print(" , ID:"); Serial.print(element._Slave_ID); Serial.print(" , PortTypes:"); Serial.print(element.PortTypes); Serial.print(" , Addr:"); Serial.print(element.Address); Serial.print(" , Local:"); Serial.print(element.LocalPort); Serial.print(" , Exp state:"); Serial.print(element.Exp_state); Serial.print(" , Exp_state_ttl"); Serial.println(element.Exp_state_ttl); if(element._Protocol == "CAN") { // if(element.PortTypes == 0x80) { Serial.println(" Prepared data"); #if defined(HAS_LCD1602) delay(LCDtim); String LCDarray1 = "P["; LCDarray1.concat(element._Protocol); LCDarray1.concat("] ID["); LCDarray1.concat(String(element._Slave_ID, HEX)); LCDarray1.concat("] T["); LCDarray1.concat(String(element.PortTypes, HEX)); LCDarray1.concat(" "); //1234567890ABCDEFGHIJKLMNOPQRTSWabcdefghijklmnopqrstwquwz // lcd.print(LCDarray1); unsigned char LCDarray1buf[15]; Serial.print(" LCDarray1 Strlen:::["); Serial.print(LCDarray1); Serial.println(" ]:::"); //char LCDarray11[] = {String(LCDarray1)}; LCDarray1.toCharArray(LCDarray1buf, 15); Serial.print(" LCDarray1BStrlen:::["); Serial.print(LCDarray1); Serial.println(" ]:::"); String LCDarray2 = " >"; LCDarray2.concat(String(element.Address, HEX)); LCDarray2.concat( "< {"); LCDarray2.concat( String(element.LocalPort, HEX)); LCDarray2.concat( "} =[" ); LCDarray2.concat(String(element.Exp_state, HEX) ); LCDarray2.concat("] ?[" ) ; LCDarray2.concat(String(element.Exp_state_ttl, HEX)) ; LCDarray2.concat("] ") ; unsigned char LCDarray2buf[16]; Serial.print(" LCDarray2 Strlen:::["); Serial.print(LCDarray2); Serial.println(" ]:::"); LCDarray2.toCharArray(LCDarray2buf, 15); Serial.print(" LCDarray2B`Strlen:::["); Serial.print(LCDarray2); Serial.println(" ]:::"); lcd.setCursor(15,0); for ( int positionCounter1 = 15; positionCounter1 < 24; positionCounter1++) { lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left. lcd.print(LCDarray1[positionCounter1]); // Print a message to the LCD. delay(LCDtim); //wait for 250 microseconds } lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner. lcd.setCursor(15,1); for ( int positionCounter2 = 15; positionCounter2 < 24; positionCounter2++) { lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left. lcd.print(LCDarray2[positionCounter2]); // Print a message to the LCD. delay(LCDtim); //wait for 250 microseconds } delay(LCDtim * 5); //wait for 250 microseconds lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner. /* lcd.print("P["); lcd.print(element._Protocol); lcd.print("]ID["); lcd.print(element._Slave_ID); lcd.print("]T["); lcd.print(element.PortTypes); */ // lcd.setCursor(0,1); // lcd.print(LCDarray2); /* lcd.print("]@["); lcd.print(element.Address); lcd.print("]|["); lcd.print(element.LocalPort); lcd.print("]=["); lcd.print(element.Exp_state); lcd.print("]?["); lcd.println(element.Exp_state_ttl); */ /* lcdPos = 14; delay(LCDtim * 5); lcd.setCursor(0,0); lcd.print(LCDarray2); lcd.setCursor(0,1); lcd.print(" "); //copy cursor to up */ #endif byte data[8] = {element.Address, element.LocalPort, element.PortTypes, element.LocalPort, element.Exp_state, element.Exp_state_ttl, 0x06, 0x07}; // } byte sndStat = CAN0.sendMsgBuf(element._Slave_ID, 0, 8, data); if(sndStat == CAN_OK){ Serial.println("Message Sent Successfully!"); String LCDarray1 = "Message Sent"; String LCDarray2 = "Successfully"; } else { Serial.println("Error Sending Message..."); String LCDarray1 = "Error Sending"; String LCDarray2 = "Message..."; } } #if defined(HAS_LCD1602) delay(LCDtim); //lcd.setCursor(0,1); lcd.print(lcdPattern); //lcd.print(lcdPos % 10); if(lcdPos >= 16) { //lcd.print("N"); lcd.setCursor(0,1); lcdPos = 0; if(lcdPattern=="s") lcdPattern = "S" ; else lcdPattern = "s" ; } lcdPos ++; #endif #if defined(HAS_TFT_ILI9163C) delay(LCDtim); display.setCursor(0,60); display.print(LCDarray1); display.print(" "); display.print(LCDarray2); #endif delay(5000); // send data per 100ms } // byte sndStat = CAN0.sendMsgBuf(_Slave1_ID, 0, 8, data);