Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hi i am getting modbus poll pc application timeout error Could you please help me #87

Open
paxsipornax opened this issue Dec 7, 2021 · 1 comment

Comments

@paxsipornax
Copy link

#include <ModbusSlave.h>
#include <SoftwareSerial.h>
SoftwareSerial RS485Serial(10, 11); // RX, TX

Modbus slave(RS485Serial, 1, 2);

int led = 12;

int dl_ro = 2;

void setup() {

pinMode(dl_ro, OUTPUT);
pinMode(led, OUTPUT);

slave.cbVector[CB_WRITE_COILS] = writeDigitalOut;

RS485Serial.begin(9600);
slave.begin(9600);

}

void loop() {
slave.poll();
}

uint8_t writeDigitalOut(uint8_t fc, uint16_t address, uint16_t length) {
Serial.print("FC=05: ");
Serial.println(fc);
Serial.println(address);
Serial.println(length);

if (address == led) {
digitalWrite(12, slave.readCoilFromBuffer(0));
}

return STATUS_OK;

}

@Erfan12699
Copy link

use arduino?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants