28
API-FDX Linux Getting Started Manual
GmbH
Section 8 – Programming the API-FDX Module
8.1.6. Setting up a Generic Transmitter Port
void MyFdxSetupTxPort()
{
TY_FDX_TX_MODE_CTRL x_TxModeCtrl;
TY_FDX_TX_QUEUE_SETUP x_TxQueueCreate;
TY_FDX_TX_QUEUE_INFO x_TxQueueInfo;
AiUInt8 Dt[100];
struct my_Frame_tag
{
TY_FDX_TX_FRAME_HEADER x_Frame;
AiUInt8 uc_Data[1000];
} My_Frame;
int i;
//--- mode control -> Set TX port to Generic mode
x_TxModeCtrl.ul_TransmitMode = FDX_TX_GENERIC;
FdxCmdTxModeControl(g_ulPort1Handle, &x_TxModeCtrl);
//--- Create Generic Tx Message Queue
x_TxQueueCreate.ul_QueueSize = 0;
x_TxQueueCreate.ul_QueueType = FDX_TX_QUEUE_CYCLIC;
FdxCmdTxQueueCreate(g_ulPort1Handle, &x_TxQueueCreate, &x_TxQueueInfo);
//--- Create 2 Frames for the Tx Queue
My_Frame.x_Frame.uc_FrameType = FDX_TX_FRAME_STD;
My_Frame.x_Frame.x_FrameAttrib.uc_DelayPort = FDX_TX_FRAME_DLY_A;
My_Frame.x_Frame.x_FrameAttrib.uc_ExternalStrobe = FDX_DIS;
My_Frame.x_Frame.x_FrameAttrib.uc_FrameStartMode=
FDX_TX_FRAME_START_PGWT
;
My_Frame.x_Frame.x_FrameAttrib.uc_PayloadBufferMode=
FDX_TX_FRAME_PBM_STD;
My_Frame.x_Frame.x_FrameAttrib.uc_PayloadGenerationMode=
FDX_TX_FRAME_PGM_USER;
My_Frame.x_Frame.x_FrameAttrib.uc_PreambleCount = FDX_TX_FRAME_PRE_DEF;
My_Frame.x_Frame.x_FrameAttrib.ul_BufferQueueHandle = 0;
My_Frame.x_Frame.x_FrameAttrib.ul_InterFrameGap = 1000;
My_Frame.x_Frame.x_FrameAttrib.ul_PacketGroupWaitTime = 1000;
My_Frame.x_Frame.x_FrameAttrib.ul_PhysErrorInjection=
FDX_TX_FRAME_ERR_OFF;
My_Frame.x_Frame.x_FrameAttrib.ul_Skew = 0;
My_Frame.x_Frame.x_FrameAttrib.uw_FrameSize = 64;
My_Frame.x_Frame.x_FrameAttrib.uw_SequenceNumberInit=
FDX_TX_FRAME_SEQ_INIT_AUTO;
My_Frame.x_Frame.x_FrameAttrib.uw_SequenceNumberOffset=
FDX_TX_FRAME_SEQ_OFFS_AUTO;
//--- Frame 1 --- VL 60
for ( i = 0 ; i<1000; i++)
My_Frame.uc_Data[i] = (unsigned char) i;
//---MAC Dst= 0x03000000003c (VL 60)
Dt[
0]=0x03;Dt[
1]=0x00;Dt[
2]=0x00;Dt[
3]=0x00;Dt[
4]=0x00;Dt[
5]=0x3c;
//---MAC Src= 0x020000012120
Dt[
6]=0x02;Dt[
7]=0x00;Dt[
8]=0x00;Dt[
9]=0x01;Dt[10]=0x21;Dt[11]=0x20;
//---MAC Type/Length
Dt[12]=0x08;Dt[13]=0x00;