Hola, estoy teniendo problemas para grabar en la memoria, me podes dar una mano?
En c#:
enviarComando3(5,100, 15);
enviarComando3(5,200, 15);
etc...
private void enviarComando3(int comando, int posMemoria, int
contenido)
{
UdpRxCmdStat OnUdpRxStat = UdpRxCmdStat.OK;
Application.DoEvents();
SendStat CmdStat = SendStat.Success;
Thread.Sleep(500);
byte[] DataBytes = new byte[3];
DataBytes[0] = (byte)comando;
DataBytes[1] = (byte)posMemoria;
DataBytes[2] = (byte)contenido;
Placa.Cmd.Udp.Send(DataBytes, out OnUdpRxStat);
}
En placa:
PlcMain()
{
Stx570_Init(0)
Stx570_Init(1)
Stx570_Init(2)
Stx570_Init(3)
UdpRxBufFlush()
UdpRxSetEvent()
while(1) {
sleep(200)
EepromReadByte(100, var1)
DelayMS(100)
EepromReadByte(200, var2)
DelayMS(100)
EepromReadByte(300, var3)
DelayMS(100)
EepromReadByte(400, var4)
DelayMS(100)
EepromReadByte(500, lunes)
DelayMS(100)
EepromReadByte(600, martes)
DelayMS(100)
EepromReadByte(700, miercoles)
DelayMS(100)
EepromReadByte(800, jueves)
DelayMS(100)
EepromReadByte(900, viernes)
DelayMS(100)
EepromReadByte(1000, sabado)
DelayMS(100)
EepromReadByte(1100, domingo)
DelayMS(100)
LcdClear()
LcdPrintf(0, 0,
"%d%d%d%d%d%d%d",lunes,martes,miercoles,jueves,viernes,sabado,domingo)
LcdPrintf(0, 1, "%d:%d %d:%d %d:%d",var1,var2,var3,var4,var1,var2)
}
}
// Función del evento @OnUdpRx().
@OnUdpRx()
{
UdpRxDataRead(RxData, 0, 3, false)
UdpRxBufFlush()
if(RxData[0] == 5)
{
EepromWriteByte(RxData[1],RxData[2])
}
}
El problema es que no guarda los datos, a veces si.