// get the slave:
ModbusSlave slave = modbusPalProject.getModbusSlave(slaveID);
// retrive the pdu processor for the modbus function:
ModbusPduProcessor mspp = slave.getPduProcessor(functionCode);
if( mspp == null )
{
System.err.println("Unsupported function code "+functionCode);
//int length = makeExceptionResponse(functionCode,XC_ILLEGAL_FUNCTION, buffer, offset);
//ModbusPalRecorder.recordOutgoing(slaveID,buffer,offset,length);
req.notifyExceptionResponse();
modbusPalProject.notifyExceptionResponse();
return -1;
}
int length = mspp.buildPDU(req, slaveID, buffer, offset, modbusPalProject.isLeanModeEnabled());
if(length==-1)
{
System.err.println("Illegal function code "+functionCode);
req.notifyPDUnotServiced();
modbusPalProject.notifyPDUnotServiced();