Description

utils/consoleRS485.h for dice-RS485 provides the following function (for <ArduinoRS485.h> & <ArduinoModbus.h> libraries) to your console application:

  • s_console_RS485() : which delivers the following commands
    • RS485 send <text> – sends on RS485 interface (PINs 7/9)
    • RS485 dump – receives data on RS485 (stop stops it)
    • RS485 temperature – reads the temperature from a slave (adr 1, input-reg 1, len 2)

Parameters

String s_console_string – String that holds the user command. Normally returned by s_console_routine() or a previous console function.

Returns

String : the user command or an empty String “” if the user command was recognised and processed by this function. (see of commands above)

Example Code:

#include "consoleLogin.h"
#include "utils/consoleRS485.h"

void setup() {
  RS485.begin();
  console_init(&Serial);
}
void loop() {
  String s_console_string = s_console_routine();  
  s_console_RS485(s_console_string);
}

Notes and Warnings

This console-function and its commands are helpful to test and learn to work with the RS485 port and the <ArduinoRS485.h> & <ArduinoModbus.h> libraries. See the source code as example code for your own application:

C:\Users\yourName\AppData\Local\Arduino15\packages\dice\hardware\samc\1.0.0\libraries\Console\src\...

In a ‘real world’ application, the s_console_RS485() function should not be required but during development it could be helpful.

Please keep in mind that each included file and its used function increase the size of the resulting application. So in order to keep the application binaries as small as possible, include only functions that are really necessary for the final application.

An example can be found in the Arduino IDE menu:
File -> Examples -> Consoles -> Dev_Console

See also

ArduinoModbus.h – library
ArduinoRS485.h -library