Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ Electronics
➜ Microprocessors
➜ RS485 compile errors
Postings by administrators only.
Refresh page
Posted by
| PyrotechMick
(3 posts) Bio
|
Date
| Wed 18 Apr 2012 03:56 AM (UTC) |
Message
| Hi Nick (and others),
I copied the example code out of your RS485 thread into two new Arduino sketches. Also downloaded and copied the RS485_protocol folder into the Libraries directory. Upon compiling the sketch, I get the following errors:
GammonMaster.cpp: In function 'void fWrite(byte)':
GammonMaster:11: error: 'rs485' was not declared in this scope
GammonMaster.cpp: In function 'int fAvailable()':
GammonMaster:16: error: 'rs485' was not declared in this scope
GammonMaster.cpp: In function 'int fRead()':
GammonMaster:21: error: 'rs485' was not declared in this scope
GammonMaster.cpp: In function 'void setup()':
GammonMaster:26: error: 'rs485' was not declared in this scope
Any idea what's going wrong? I tried compiling this in IDE 1.0 and 0022. Forgive me if I've overlooked something simple. Thanks for your help. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 19 Apr 2012 10:47 AM (UTC) |
Message
| Did you install the library? And restart the IDE afterwards? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| PyrotechMick
(3 posts) Bio
|
Date
| Reply #2 on Thu 19 Apr 2012 02:12 PM (UTC) |
Message
| Yes, the library is installed, and I restarted the IDE several times. To confirm, RS485_protocol does show up in the Library menu. Thanks. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #3 on Fri 20 Apr 2012 10:00 AM (UTC) |
Message
| Perhaps I didn't upload the latest version which handles 1.0 version of the IDE. Try re-downloading, and changing NewSoftSerial to SoftwareSerial. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| PyrotechMick
(3 posts) Bio
|
Date
| Reply #4 on Mon 23 Apr 2012 03:37 AM (UTC) |
Message
| Got it to compile! I have to confess, this might have been nothing more than an "ID10T" error... I had commented-out the line that defined the SoftwareSerial ports (since I'll be using hardware serial) but neglected to change the lines containing "rs485." to "Serial." Obviously I'm still learning. Forgive me for any confusion I've caused! | Top |
|
Posted by
| ChrisHem
USA (3 posts) Bio
|
Date
| Reply #5 on Thu 13 Dec 2012 04:53 PM (UTC) |
Message
| I've got your libraries installed (both the normal and non-blocking versions), however my compile is choking on both the "sendMsg" and "recvMsg" areas.
I'm pretty sure I've missed something simple, but I can't figure it out.
Any advice? :) | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #6 on Thu 13 Dec 2012 08:30 PM (UTC) |
Message
| Post your code please? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| ChrisHem
USA (3 posts) Bio
|
Date
| Reply #7 on Thu 13 Dec 2012 09:22 PM (UTC) Amended on Thu 13 Dec 2012 09:23 PM (UTC) by ChrisHem
|
Message
| 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
| Top |
|
Posted by
| ChrisHem
USA (3 posts) Bio
|
Date
| Reply #8 on Thu 13 Dec 2012 09:28 PM (UTC) |
Message
| Figured it out.
I was including the "rs485_non_blocking", but did not include "rs485_protocol".
Including rs485_protocol fixed it!
Thank you for the quick response, though! | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #9 on Fri 14 Dec 2012 12:45 AM (UTC) |
Message
| Your code as posted seems to combine the non-blocking and blocking code. If you want blocking, just use the "RS485_protocol.h" file. Otherwise include the other file. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
25,662 views.
Postings by administrators only.
Refresh page
top