[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  Electronics
. -> [Folder]  Microprocessors
. . -> [Subject]  RS485 compile errors

RS485 compile errors

Postings by administrators only.

[Refresh] Refresh page


Posted by PyrotechMick   (3 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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
[Go to top] top

Posted by PyrotechMick   (3 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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
[Go to top] top

Posted by PyrotechMick   (3 posts)  [Biography] 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!
[Go to top] top

Posted by ChrisHem   USA  (3 posts)  [Biography] 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? :)
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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
[Go to top] top

Posted by ChrisHem   USA  (3 posts)  [Biography] 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
[Go to top] top

Posted by ChrisHem   USA  (3 posts)  [Biography] 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!
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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
[Go to top] 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.


23,039 views.

Postings by administrators only.

[Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]