Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion examples/TCP/EthernetModbusServerLED/EthernetModbusServerLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#include <SPI.h>
#include <Ethernet.h>
#if defined(ARDUINO_ARCH_ZEPHYR)
#include <ZephyrServer.h>
#endif

#include <ArduinoRS485.h> // ArduinoModbus depends on the ArduinoRS485 library
#include <ArduinoModbus.h>
Expand All @@ -26,7 +29,11 @@ byte mac[] = {
};
IPAddress ip(192, 168, 1, 177);

#if defined(ARDUINO_ARCH_ZEPHYR)
ZephyrServer ethServer(502);
#else
EthernetServer ethServer(502);
#endif

ModbusTCPServer modbusTCPServer;

Expand Down Expand Up @@ -81,8 +88,12 @@ void setup() {

void loop() {
// listen for incoming clients
#if defined(ARDUINO_ARCH_ZEPHYR)
EthernetClient client = ethServer.accept();
#else
EthernetClient client = ethServer.available();

#endif

if (client) {
// a new client connected
Serial.println("new client");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
*/

#include <SPI.h>
#if defined(ARDUINO_ARCH_ZEPHYR)
#include <WiFi.h>
#else
#include <WiFiNINA.h> // for MKR WiFi 1010
// #include <WiFi101.h> // for MKR1000
#endif

#include <ArduinoRS485.h> // ArduinoModbus depends on the ArduinoRS485 library
#include <ArduinoModbus.h>
Expand Down
15 changes: 14 additions & 1 deletion examples/TCP/WiFiModbusServerLED/WiFiModbusServerLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
*/

#include <SPI.h>
#if defined(ARDUINO_ARCH_ZEPHYR)
#include <WiFi.h>
#include <ZephyrServer.h>
#else
#include <WiFiNINA.h> // for MKR WiFi 1010
// #include <WiFi101.h> // for MKR1000
#endif

#include <ArduinoRS485.h> // ArduinoModbus depends on the ArduinoRS485 library
#include <ArduinoModbus.h>
Expand All @@ -28,7 +33,11 @@ const int ledPin = LED_BUILTIN;

int status = WL_IDLE_STATUS;

#if defined(ARDUINO_ARCH_ZEPHYR)
ZephyrServer wifiServer(502);
#else
WiFiServer wifiServer(502);
#endif

ModbusTCPServer modbusTCPServer;

Expand Down Expand Up @@ -74,8 +83,12 @@ void setup() {

void loop() {
// listen for incoming clients
#if defined(ARDUINO_ARCH_ZEPHYR)
WiFiClient client = wifiServer.accept();
#else
WiFiClient client = wifiServer.available();

#endif

if (client) {
// a new client connected
Serial.println("new client");
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ sentence=Use Modbus equipment with your Arduino.
paragraph=Using TCP or RS485 shields, like the MKR 485 Shield. This library depends on the ArduinoRS485 library.
category=Communication
url=https://www.arduino.cc/en/ArduinoModbus/ArduinoModbus
architectures=megaavr,samd,mbed_nano,mbed_portenta,mbed_opta
architectures=megaavr,samd,mbed_nano,mbed_portenta,mbed_opta,zephyr,zephyr_main,zephyr_contrib
includes=ArduinoModbus.h
depends=ArduinoRS485
2 changes: 1 addition & 1 deletion src/ModbusClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ const char* ModbusClient::lastError()
return NULL;
}

return modbus_strerror(errno);
return modbus_strerror(errno);
}

void ModbusClient::setTimeout(unsigned long ms)
Expand Down
1 change: 1 addition & 0 deletions src/libmodbus/modbus-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct timeval {
uint32_t tv_usec;
};
#else
# include <sys/select.h>
# include <sys/time.h>
#endif
#else
Expand Down
1 change: 1 addition & 0 deletions src/libmodbus/modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef DEBUG
#define printf(...) {}
#define fprintf(...) {}
#define vfprintf(...) {}
#endif
#endif

Expand Down
Loading