It's pretty much an exact copy of one of your examples.
#include "RS485_non_blocking.h"
#include <SoftwareSerial.h>
const byte ENABLE_PIN=4;
const byte LED_PIN=13;
SoftwareSerial rs485(2,3);
// callback routines
void fWrite( const byte what ){
rs485.print(what);
}
int fAvailable(){
return rs485.available();
}
int fRead(){
return rs485.read();
}
void setup(){
rs485.begin(28800); //28.8kbaud!
pinMode( ENABLE_PIN, OUTPUT );
pinMode( LED_PIN, OUTPUT );
}
byte old_level=0;
void loop(){
// read potentiometer
byte level=analogRead(0)/4; // (scales 0-1023 down to 0-254)
// no change in level, no transmit
if ( level == old_level ){
return;
}
byte msg[] = { // I think this is the protocol right here...
1, // Device 1
2, // Turn light on
level // to what level
};
// send to slave
digitalWrite( ENABLE_PIN, HIGH); // enable sending
sendMsg ( fWrite, msg, sizeof msg );
digitalWrite( ENABLE_PIN, LOW); // disable sending
// receive response
byte buf[10];
byte received = recvMsg( fAvailable, fRead, buf, sizeof buf);
digitalWrite(LED_PIN, received==0); // turn on LED if error
// only send once per successful change
if ( received ){
old_level = level;
}
}
And this is the error I'm getting:
RS485_General__1.cpp: In function 'void loop()':
RS485_General__1:47: error: 'sendMsg' was not declared in this scope
RS485_General__1:52: error: 'recvMsg' was not declared in this scope
|