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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
But it doesn't give any response to messages that I send to it
#define SerialTxControl 3 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
#define Pin13LED 13
const int MSGL = 13;
const int MSGL2 = 6;
byte Byte[MSGL];
byte Trigger[MSGL2];
unsigned long Timer = 0;
void setup() /****** SETUP: RUNS ONCE ******/
{
Byte[0] = 195;
Byte[1] = 255;
Byte[2] = 245;
Byte[3] = 8; //Bytes of data sent
Byte[4] = 'M';
Byte[5] = 0; // Sign Number 0 will brodcast to all
Byte[6] = 1; //
Byte[7] = 0; // Horizontal position
Byte[8] = 'G';
Byte[9] = 'D';
Byte[10] = 'F';
Byte[11] = 'W';
Trigger[0] = 195;
Trigger[1] = 255;
Trigger[2] = 245;
Trigger[3] = 1; //Byte Counts of Following Data
Trigger[4] = 'T';// Message Type
// Start the built-in serial port, probably to Serial Monitor
Serial.begin(9600);
Serial1.begin(9600);
pinMode(Pin13LED, OUTPUT);
pinMode(SerialTxControl, OUTPUT);
digitalWrite(SerialTxControl, RS485Transmit); // Init Transceiver
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
digitalWrite(SerialTxControl, RS485Receive);
if(Serial1.available() > 0) {
Timer = millis();
}
if (millis() - Timer > 5000) {
TransmitMessage();
Timer = millis();
}
ReadSerial2();
}//--(end main loop )---
void ReadSerial2() {
digitalWrite(SerialTxControl, RS485Receive); // Init Transceiver
// Declarations
unsigned char sBuffer[100];
// digitalWrite(RSE, HIGH);
// Check for RS485 data
int nBytes = Serial1.available();
if(nBytes > 0)
{
int nCount = Serial1.readBytes(sBuffer, nBytes);
for(int nIndex = 0; nIndex < nCount; nIndex++)
{
Serial.print(sBuffer[nIndex], HEX);
Serial.print(" ");
}// end for
} //end if
}// end loop
void TransmitMessage(){
digitalWrite(SerialTxControl, RS485Transmit); // Init Transceiver
byte chk = 0;
for ( int i=0; i<(MSGL-1); i++) { //length = 19 (22-02 = 20 - 1)
chk += Byte[i];
}
Byte[12] = chk;
//sum=10+C1+00+00+00+3E+90+32+00+21+16+10+1E+11+01+33+C1+0A+CD+19 = 042C
//discard accumulated carries; we get 2C = 0010 1100
//take 2's complemet code : 1101 0011 + 1 = D4
Serial.println("WriteM");
for ( int i=0; i<MSGL; i++) { //length = 19 (22-02 = 20 - 1)
Serial1.write(Byte[i]);
Serial.println(Byte[i]);
}
chk = 0;
for ( int i=0; i<(MSGL2-1); i++) { //length = 19 (22-02 = 20 - 1)
chk += Byte[i];
}
Trigger[5] = chk;
Serial.println("WriteT");
for ( int i=0; i<MSGL2; i++) { //length = 19 (22-02 = 20 - 1)
Serial1.write(Trigger[i]);
Serial.println(Trigger[i]);
}
}
[code/]
The manual says that the communications uses serial ASCII, and I'm still trying to figure out if I should be using serial.print or serial.write to get that format.