Forum Controladores/PLC

Welcome!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

[ESP] Error comunicación RS485

Avatar
Domenec

Hola, estoy usando la Industrial Shield ESP32 PLC 38AR+.

Usando la demo de la libreria RS485 salta un error crítico al intentar enviar un dato.


Core  1 register dump:
PC      : 0x4008a9a2  PS      : 0x00060035  A0      : 0x80089bfa  A1      : 0x3ffbedbc  
A2      : 0x3ffb9580  A3      : 0x3ffb8890  A4      : 0x00000004  A5      : 0x00060023  
A6      : 0x00060023  A7      : 0x00000001  A8      : 0x3ffb8890  A9      : 0x00000018  
A10     : 0x3ffb8890  A11     : 0x00000018  A12     : 0x3ffc15fc  A13     : 0x00060023  
A14     : 0x007beec8  A15     : 0x003fffff  SAR     : 0x0000001c  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x40086048  LEND    : 0x4008605e  LCOUNT  : 0xffffffff  
Core  1 was running in ISR context:
EPC1    : 0x400db7cb  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x00000000


Backtrace:0x4008a99f:0x3ffbedbc |<-CORRUPTED


Core  0 register dump:
PC      : 0x4008ab27  PS      : 0x00060035  A0      : 0x80089823  A1      : 0x3ffbe81c  
A2      : 0x3ffbeec8  A3  ⸮

El código es el siguiente:


#include <RS485.h>

// Function to calculate the CRC byte
byte calculateCRC(byte* data, byte length) {
  byte crc = 0;
  for (byte i = 0; i < length; i++) {
    crc ^= data[i];
  }
  return crc;
}



unsigned long lastSent;
byte dir = 0x01;
byte codlong = 0*32+3;
byte crc;
byte data;
byte dataSize = sizeof(data);

void setup() {
  Serial.begin(9600);
  RS485.begin(19200L);
  lastSent = millis();
  crc = calculateCRC(&data, dataSize);

}
void loop() {

if(millis() - lastSent >= 5000){
  Serial.println("Sending the packet...");
  RS485.write(dir);
//  RS485.write(codlong);
//  RS485.write(data);
//  RS485.write(crc);
  lastSent = millis();
}
}

Segun tengo enetendido el codigo es una violación de acceso a la memoria cpu , pero no tengo claro porque ocurre.

Lo mas probable es que sean los switches ya que no termino de entender como tengo que ponerlos para usar la comunicación. La mayoria estan etiquietados a NC , que entiendo que siginifica not connected.


Un saludo.


Avatar
Descartar
1 Respuesta
0
Mejor respuesta

Había un error con nuestras librerías. Ya está arreglado en la actualización 2.1.3.

Avatar
Descartar