1.4.1.2 Transmission
In the PLC & Go application, to transmit a message it is only needed to call the
function APP_PLC_SendData
, passing as parameters the pointer to the
data buffer and the data length. The function includes the length of the message to
transmit in the first two bytes of the data buffer, so that at the reception of the
message it is possible to know the real length of the message.
Any message transmitted by the PLC PHY requires some transmission parameters. These
parameters and the pointer to data are stored in the structure DRV_PLC_PHY_TRANSMISSION_OBJ
.
The PLC & Go application only allows the configuration of some transmission
parameters related to the modulation. The rest of the transmission parameters are
configured by default during the initialization stage in the state
APP_PLC_STATE_IDLE
. The Tone Map is configured to use all carriers
in the function APP_PLC_SetInitialConfiguration
in the state
APP_PLC_STATE_OPEN
, depending on the frequency band used.
In G3-PLC PHY, the maximum PSDU length depends on the modulation, number of Reed-Solomon
blocks, Tone Mask and Tone Map. The PIBs PLC_ID_MAX_PSDU_LEN_PARAMS
and
PLC_ID_MAX_PSDU_LEN
can be used to know the maximum PSDU length for
the given parameters, as it is done in the function
APP_PLC_SetModScheme
.
APP_PLC_SendData
prepares the data to be sent by PLC, storing the
data in the transmission buffer (appPlcTxDataBuffer
), adding the data
length in the first two bytes and storing the data length in the transmission parameters
structure (appPlcTx.plcPhyTx.dataLength
). When all the information is
in the transmission parameters structure and the data buffer, the function
DRV_PLC_PHY_TxRequest
is called to request the transmission of the
message to the PHY
layer.bool APP_PLC_SendData ( uint8_t* pData, uint16_t length )
{
if (appPlc.state == APP_PLC_STATE_WAITING)
{
if (appPlc.pvddMonTxEnable)
{
if ((length > 0) && ((length + 2) <= APP_PLC_BUFFER_SIZE))
{
/* Fill 2 first bytes with data length */
/* Physical Layer may add padding bytes in order to complete symbols with data */
/* It is needed to include real data length in the message because otherwise at reception is not possible to know if there is padding or not */
appPlcTx.pDataTx[0] = length >> 8;
appPlcTx.pDataTx[1] = length & 0xFF;
/* Set data length in Tx Parameters structure */
/* It should be equal or less than Maximum Data Length (see APP_PLC_SetModScheme) */
/* Otherwise DRV_PLC_PHY_TX_RESULT_INV_LENGTH will be reported in Tx Confirm */
appPlcTx.plcPhyTx.dataLength = length + 2;
memcpy(appPlcTx.pDataTx + 2, pData, length);
appPlc.plcTxState = APP_PLC_TX_STATE_WAIT_TX_CFM;
DRV_PLC_PHY_TxRequest(appPlc.drvPlcHandle, &appPlcTx.plcPhyTx);
/* Set PLC state */
if (appPlc.plcTxState == APP_PLC_TX_STATE_WAIT_TX_CFM)
{
appPlc.state = APP_PLC_STATE_WAITING_TX_CFM;
return true;
}
}
}
}
return false;
}
Due to G3-PLC requirements, before sending the message, the data buffer needs to be
accommodated adding some padding bytes if necessary. Zero byte padding is used to fit
the encoded bits into an integer number of OFDM symbols (multiple of 4 in the case of
CENELEC-A/B bands). In the example, the PHY layer is configured to add padding and CRC
automatically, enabling the PIB PLC_ID_CRC_TX_RX_CAPABILITY
.
Once the PHY layer finishes the PLC transmission (successfully or not), a transmission
data confirm event is triggered indicating the result of the transmission. This event is
managed by the APP_PLC_DataCfmCb
callback function. This callback
receives as parameter a data structure of type DRV_PLC_PHY_TRANSMISSION_CFM_OBJ
.
- Structure
DRV_PLC_PHY_TRANSMISSION_OBJ
The transmission parameters are stored in the data structureDRV_PLC_PHY_TRANSMISSION_OBJ
, defined in drv_plc_phy_comm.h:
Where:// ***************************************************************************** /* G3 Transmission setup data Summary This struct includes all information to describe any transmissions. Remarks: None */ typedef struct __attribute__((packed, aligned(1))) { /* Pointer to data buffer to transmit */ uint8_t *pTransmitData; /* Instant when transmission has to start referred to 1us PHY counter */ uint32_t time; /* Length of the data to transmit in bytes */ uint16_t dataLength; /* Preemphasis for transmission */ uint8_t preemphasis[NUM_SUBBANDS_MAX]; /* Tone Map to use on transmission */ uint8_t toneMap[TONE_MAP_SIZE_MAX]; /* Transmission Mode (absolute, relative, forced, continuous, cancel). Constants above */ uint8_t mode; /* Power to transmit */ uint8_t attenuation; /* Phase Detector Counter */ uint8_t pdc; /* Flag to indicate whether 2 Reed-Solomon blocks have to be used (only used for FCC) */ uint8_t rs2Blocks; /* Modulation type */ DRV_PLC_PHY_MOD_TYPE modType; /* Modulation scheme */ DRV_PLC_PHY_MOD_SCHEME modScheme; /* DT field to be used in header */ DRV_PLC_PHY_DEL_TYPE delimiterType; } DRV_PLC_PHY_TRANSMISSION_OBJ;
pTransmitData
: Pointer to the buffer containing the data to transmit.time
: Instant when transmission has to start referred to the 32-bit 1 μs PHY time counter (absolute or relative value, depending onmode
).dataLength
: Length of the data to transmit. If CRC computation is enabled (PIBPLC_ID_CRC_TX_RX_CAPABILITY
), the CRC length (two bytes) is not included.preemphasis
: Attenuation per sub-band of carriers. Not used./* Subbands for Cenelec-A bandplan */ #define NUM_SUBBANDS_CENELEC_A 6 /* Subbands for Cenelec-B bandplan */ #define NUM_SUBBANDS_CENELEC_B 4 /* Subbands for FCC bandplan */ #define NUM_SUBBANDS_FCC 24 /* Subbands for ARIB bandplan */ #define NUM_SUBBANDS_ARIB 16 /* Maximum number of subbands */ #define NUM_SUBBANDS_MAX NUM_SUBBANDS_FCC
toneMap
: Dynamic notching. Each bit corresponds to a sub-band of carriers and it indicates if such carriers carry message data (1) or pseudo-random data (0)./* Tone Map size for Cenelec(A,B) bandplan */ #define TONE_MAP_SIZE_CENELEC 1 /* Tone Map size for FCC bandplan */ #define TONE_MAP_SIZE_FCC 3 /* Tone Map size for ARIB bandplan */ #define TONE_MAP_SIZE_ARIB 3 /* Maximum number of tone map */ #define TONE_MAP_SIZE_MAX TONE_MAP_SIZE_FCC
mode
: Transmission mode bit-field.mode
bit-fieldDescription TX_MODE_ABSOLUTE The message is sent at the specified time, referred to the 32-bit PHY time counter (1 μs). Time specified in time
.TX_MODE_RELATIVE The message is sent with a delay in μs, referred to the current time. Delay specified in time
.TX_MODE_FORCED Transmission has a higher priority than a reception in progress. Carrier Detect is not checked before transmitting. TX_MODE_SYNCP_CONTINUOUS Continuous transmission of the preamble. Used for testing. TX_MODE_SYMBOLS_CONTINUOUS Continuous transmission of a message. Used for testing. TX_MODE_CANCEL Cancels the ongoing transmission (started or programmed). attenuation
: Signal attenuation (3 dB/unit, and 0 means maximum signal level). Maximum attenuation is 45 dB. 0xFF is a special value to apply zero-gain (transmit all zeros), used to measure impedance in transmission mode.pdc
: Phase detector counter. Not used, PDC is calculated and filled in the PHY header (FCH) by the PHY layer.rs2Blocks
: Flag to indicate whether two (1) or one (0) Reed-Solomon blocks have to be used (only used for FCC band).modType
: Modulation type.modType
Value Description MOD_TYPE_BPSK 0 BPSK Modulation Type MOD_TYPE_QPSK 1 QPSK Modulation Type MOD_TYPE_8PSK 2 8PSK Modulation Type MOD_TYPE_BPSK_ROBO 4 BPSK Robust (4 repetitions) Modulation Type modScheme
: Modulation scheme.modScheme
Value Description MOD_SCHEME_DIFFERENTIAL 0 Differential Modulation Scheme MOD_SCHEME_COHERENT 1 Coherent Modulation Scheme delimiterType
: Delimiter type used in the FCH.delimiterType
Value Description DT_SOF_NO_RESP 0 Acknowledgment is not requested DT_SOF_RESP 1 Acknowledgment is requested DT_ACK 2 Positive acknowledgment DT_NACK 3 Negative acknowledgment
- Structure
DRV_PLC_PHY_TRANSMISSION_CFM_OBJ
The transmission result is reported in the data structureThe transmission result can have one of the following values:DRV_PLC_PHY_TRANSMISSION_CFM_OBJ
, defined in drv_plc_phy_comm.h:// ***************************************************************************** /* G3 Result of a transmission Summary This struct includes all information to describe any result of a previous transmission. Remarks: None */ typedef struct { /* Instant when frame transmission ended referred to 1us PHY counter */ uint32_t time; /* RMS_CALC it allows to estimate tx power injected */ uint32_t rmsCalc; /* Tx Result (see "TX Result values" above) */ DRV_PLC_PHY_TX_RESULT result; } DRV_PLC_PHY_TRANSMISSION_CFM_OBJ;
// ***************************************************************************** /* G3 Result values of a previous transmission Summary This list involves all available results from MCHP implementation Remarks: None */ typedef enum { /* Transmission result: already in process */ DRV_PLC_PHY_TX_RESULT_PROCESS = 0, /* Transmission result: end successfully */ DRV_PLC_PHY_TX_RESULT_SUCCESS = 1, /* Transmission result: invalid length error */ DRV_PLC_PHY_TX_RESULT_INV_LENGTH = 2, /* Transmission result: busy channel error */ DRV_PLC_PHY_TX_RESULT_BUSY_CH = 3, /* Transmission result: busy in transmission error */ DRV_PLC_PHY_TX_RESULT_BUSY_TX = 4, /* Transmission result: busy in reception error */ DRV_PLC_PHY_TX_RESULT_BUSY_RX = 5, /* Transmission result: invalid modulation scheme error */ DRV_PLC_PHY_TX_RESULT_INV_SCHEME = 6, /* Transmission result: timeout error */ DRV_PLC_PHY_TX_RESULT_TIMEOUT = 7, /* Transmission result: invalid tone map error */ DRV_PLC_PHY_TX_RESULT_INV_TONEMAP = 8, /* Transmission result: invalid modulation type error */ DRV_PLC_PHY_TX_RESULT_INV_MODTYPE = 9, /* Transmission result: invalid delimiter type error */ DRV_PLC_PHY_TX_RESULT_INV_DT = 10, /* Transmission result: transmission cancelled */ DRV_PLC_PHY_TX_CANCELLED = 11, /* Transmission result: high temperature error */ DRV_PLC_PHY_TX_RESULT_HIGH_TEMP_120 = 12, /* Transmission result: high temperature warning */ DRV_PLC_PHY_TX_RESULT_HIGH_TEMP_110 = 13, /* Transmission result: No transmission ongoing */ DRV_PLC_PHY_TX_RESULT_NO_TX = 255, }DRV_PLC_PHY_TX_RESULT;