Hallo zusammen,
gerade will ich zwischen zwei Atmega328P-PU über MAX487-Bausteine eine Kommunikation aufbauen.
Ich nutze dafür diese Vorlage: Gammon Forum : Electronics : Microprocessors : RS485 communications
Allerdings bekomm ich beim Kompilieren immer einen Fehler:
(im orangen Kasten:)
"invalid conversion form ‘byte’ to ‘const bate*’
(im schwarzen Kasten:)
“In function ‘void loop()’:
error: invalied conversion from ‘byte’ to ‘const byte*’
error: initializing argument 2 of ‘void sendMsg(void ()(byte), const byte, byte)’
error: invalid conversion from ‘byte’ to ‘byte*’
error: initializing argument 3 of ‘byte recvMsg(int ()(), int ()(), byte*, byte, lang unsigned int)’”
Der Sketch:
#include <RS485_protocol.h>
#include <SoftwareSerial.h>
const byte ENABLE_PIN = 4;
const byte LED_PIN = 9;
SoftwareSerial rs485(2, 3);
void fWrite (const byte what)
{
rs485.write (what);
}
int fAvailable()
{
return rs485.available();
}
int fRead()
{
return rs485.read();
}
void setup()
{
rs485.begin (288000);
pinMode(ENABLE_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
}
void loop()
{
if (digitalRead(8) == LOW)
{
const byte msg = 1;
digitalWrite(ENABLE_PIN, HIGH);
sendMsg (fWrite, msg, sizeof msg);
digitalWrite(ENABLE_PIN, LOW);
delay(1000);
byte buf;
byte received = recvMsg (fAvailable, fRead, buf, 1);
if (buf == 1)
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
}
}
}
Und gelb hervorgehoben wird immer die Zeile
sendMsg (fWrite, msg, sizeof msg);
Ich hab keine Ahnung, wie das das beheben kann, hab schon versucht, die variablen auch auf const zu setzen, irgendwie hat nichts geholfen.
LG
Fipsi