1.2.3.1 How the Library Works

PLC PHY API Serialization

PLC Serial library allow accessing to PLC PHY Driver API through a Serial interface. Library manages commands coming from a Serial interface through the USI library, these commands include access to PLC Transmission primitives and also access to read/write parameters of the PHY Information Base (PIBs). On the other direction, library sends the received PLC frames through the Serial interface, as well as the resulting status of a requested transmission or PIB access.

A tool is required at the other side of the Serial interface, to send and receive commands. For this purpose, Microchip offers 2 different options:

  • Microchip Phy Tester Tool. A GUI which allows sending and receiving PLC frames, and accessing the PHY Information Base.

  • Microchip PLC Python Libs. A set of Python libraries that allow easily building scripts on top of them to perform sending, receiving and configuring operations.

Commands Accepted by Library

Serial library accepts commands for PLC frame trasnmission and PIB access. The following list describes these commands and their behaviour:

  • SRV_PSERIAL_CMD_PHY_SEND_MSG. This command is followed by a serialized stream that contains the frame to be sent to PLC and the transmission paramters. Upon reception of this command, Serial library generates a PLC transmission object and requests transmission to the PLC PHY Driver.

  • SRV_PSERIAL_CMD_PHY_GET_CFG. This command is followed by the identifier of the PIB object to be retrieved. Upon reception of this command, the PIB is retrieved from the PLC transceiver and a response command (SRV_PSERIAL_CMD_PHY_GET_CFG_RSP) is generated to send back the value and result of the Get operation.

  • SRV_PSERIAL_CMD_PHY_SET_CFG. This command is followed by the identifier of the PIB object to be set. Upon reception of this command, the PIB is written to the PLC transceiver and a response command (SRV_PSERIAL_CMD_PHY_SET_CFG_RSP) is generated to send back the result of the Set operation.

Commands Generated by Library

Serial library generates commands, either by itself or as a response to requested commands, to indicate PLC frame reception, PLC transmission result and PIB access result. The following list describes these commands and the evenst that generate them:

  • SRV_PSERIAL_CMD_PHY_RECEIVE_MSG. This command is generated upon reception of a PLC frame from the PLC PHY Driver. The command is followed by the received frame and reception related parameters.

  • SRV_PSERIAL_CMD_PHY_SEND_MSG_RSP. This command is generated upon confirm of a transmitted (or aborted trasnsmission) PLC frame from the PLC PHY Driver. The command is followed by the transmission result or the error code in case of transmission failure.

  • SRV_PSERIAL_CMD_PHY_GET_CFG_RSP. This command is generated as a response to a PIB Get command (SRV_PSERIAL_CMD_PHY_GET_CFG) and is follwed by the Get operation result and (if successful) the retrieved value of the Get operation.

  • SRV_PSERIAL_CMD_PHY_SET_CFG_RSP. This command is generated as a response to a PIB Set command (SRV_PSERIAL_CMD_PHY_SET_CFG) and is follwed by the Set operation result.