📄 cli.c
字号:
{
TB640FskDisplayAdapterStats (un32Count);
}
/* Take a snapshot of the stats */
TBX_SEM_GET (g_StressStatsSem, TBX_SEM_WAIT_FOREVER);
memcpy ((char *)&StatsCopy, (char *)&g_StressStats, sizeof(g_StressStats));
TBX_SEM_GIV (g_StressStatsSem);
/* Calculate the number of calls per seconds and BHCA value */
if (StatsCopy.un32StartTimestamp != StatsCopy.un32CurrentTimestamp)
{
un32TimeSinceBegInSec = ((StatsCopy.un32CurrentTimestamp - StatsCopy.un32StartTimestamp)/1000);
if (un32TimeSinceBegInSec > 0)
{
un32NbRxFskMsgPerSeconds = StatsCopy.un32NbRxPackets / un32TimeSinceBegInSec;
un32NbTxFskMsgPerSeconds = StatsCopy.un32NbTxPackets / un32TimeSinceBegInSec;
un32NbRxFskAckPerSeconds = StatsCopy.un32NbRxAck / un32TimeSinceBegInSec;
un32NbTxFskAckPerSeconds = StatsCopy.un32NbTxAck / un32TimeSinceBegInSec;
}
else
{
un32NbRxFskMsgPerSeconds = 0;
un32NbTxFskMsgPerSeconds = 0;
un32NbRxFskAckPerSeconds = 0;
un32NbTxFskAckPerSeconds = 0;
}
}
else
{
un32NbRxFskMsgPerSeconds = 0;
un32NbTxFskMsgPerSeconds = 0;
un32NbRxFskAckPerSeconds = 0;
un32NbTxFskAckPerSeconds = 0;
}
/* Prints the stats */
TB640_FSK_DISPLAY_PRINT ("\n");
TB640_FSK_DISPLAY_PRINT ("\tRx FSK messages per sec. : %08d Tx FSK messages per sec. : %08d\n",
un32NbRxFskMsgPerSeconds, un32NbTxFskMsgPerSeconds);
TB640_FSK_DISPLAY_PRINT ("\tRx FSK messages total : %08d Tx FSK messages total : %08d\n",
StatsCopy.un32NbRxPackets, StatsCopy.un32NbTxPackets);
TB640_FSK_DISPLAY_PRINT ("\tRx FSK ack per sec. : %08d Tx FSK ack per sec. : %08d\n",
un32NbRxFskAckPerSeconds, un32NbTxFskAckPerSeconds);
TB640_FSK_DISPLAY_PRINT ("\tRx FSK ack total : %08d Tx FSK ack total : %08d\n",
StatsCopy.un32NbRxAck, StatsCopy.un32NbTxAck);
TB640_FSK_DISPLAY_PRINT ("\tUnexpected Rx (while Tx state): %08d Unexpected Rx (while Rx state): %08d\n",
StatsCopy.un32NbRxWhileTxState, StatsCopy.un32NbRxWhileRxState);
TB640_FSK_DISPLAY_PRINT ("\tUnexpected Rx (other) : %08d Unexpected FSK ack : %08d\n",
StatsCopy.un32NbUnexpectedRx, StatsCopy.un32NbUnexpectedAck);
TB640_FSK_DISPLAY_PRINT ("\tRx sequences completed : %08d Tx sequences completed : %08d\n",
StatsCopy.un32NbRxSeqCompleted, StatsCopy.un32NbTxSeqCompleted);
TB640_FSK_DISPLAY_PRINT ("\t Tx retransmitted : %08d\n",
StatsCopy.un32NbTxRetransmit);
TB640_FSK_DISPLAY_PRINT ("\tRx sequences timeout : %08d Tx sequences timeout : %08d\n",
StatsCopy.un32NbRxSeqTimeout, StatsCopy.un32NbTxSeqTimeout);
TB640_FSK_DISPLAY_PRINT ("\tNo free tmslot for stress tst : %08d Nb elapsed sec. since start : %08d\n",
StatsCopy.un32NbCallNoFreeTimeslotToSend, ((StatsCopy.un32CurrentTimestamp - StatsCopy.un32StartTimestamp) / 1000));
TB640_FSK_DISPLAY_PRINT ("\n");
/* Display menu */
TB640_FSK_DISPLAY_PRINT ("Options:\n");
TB640_FSK_DISPLAY_PRINT ("\t(T) Enable timeslot to (T)ransmit FSK (R) Enable timeslot to (R)eceive FSK\n");
TB640_FSK_DISPLAY_PRINT ("\t(K)ick transmission sequence on timeslot (C)lear all timeslots (return to idle state)\n");
TB640_FSK_DISPLAY_PRINT ("\t(B)egin automatic call generation (S)top automatic call generation\n");
TB640_FSK_DISPLAY_PRINT ("\t(P)rint timeslot history (F)lush log file\n");
TB640_FSK_DISPLAY_PRINT ("\t(A)djust trace levels ");
TB640_FSK_DISPLAY_PRINT ("\t(Q)uit\n");
TB640_FSK_DISPLAY_PRINT ("\n");
/* Display status strings */
TB640_FSK_WRITE_STRING_CENTERED (ULS, URS, MS, TB640_FSK_CLI_MAX_LINE_SIZE, "Status window");
TB640_FSK_DISPLAY_PRINT ("\n");
TBX_SEM_GET (g_AppContext->DisplaySem, TBX_SEM_WAIT_FOREVER);
un32Count=0;
un32OldReadIndex = g_un32ErrorLineReadIndex;
while ((un32Count < TB640_FSK_CLI_MAX_NB_ERROR_LINES_VIEWED) &&
(un32OldReadIndex != g_un32ErrorLineWriteIndex))
{
if (strlen((PTBX_CHAR)g_aszErrorLines[un32OldReadIndex]) > 0)
{
TB640_FSK_DISPLAY_PRINT (TB640_FSK_CLI_LINE_DISPLAY_STRING, g_aszErrorLines[un32OldReadIndex]);
}
else
{
TB640_FSK_DISPLAY_PRINT (TB640_FSK_CLI_LINE_DISPLAY_STRING, " ");
}
un32Count++;
if (++un32OldReadIndex >= TB640_FSK_CLI_MAX_NB_ERROR_LINES)
{
un32OldReadIndex = 0;
}
}
TBX_SEM_GIV (g_AppContext->DisplaySem);
while (un32Count < TB640_FSK_CLI_MAX_NB_ERROR_LINES_VIEWED)
{
TB640_FSK_DISPLAY_PRINT (TB640_FSK_CLI_LINE_DISPLAY_STRING, " ");
un32Count++;
}
TB640_FSK_DISPLAY_PRINT ("\n");
TB640_FSK_WRITE_LINE(ULS, URS, MS, TB640_FSK_CLI_MAX_LINE_SIZE);
TB640_FSK_DISPLAY_PRINT ("\n");
}
}
/* Update the screen every seconds minimum when doing the stress testing */
if (((un32Timer / 1000) > un32TimerSec) && (fAutomaticCallGenerationActivated))
{
g_fRefreshDisplay |= (TB640_FSK_CLI_REFRESH_DISPLAY);
}
un32TimerSec = (un32Timer / 1000);
/* Update the statistic timestamps */
TB640_FSK_UPDATE_STATS (un32CurrentTimestamp, un32Timer);
/* Is there a key stroke ? */
if (TBXCliKeyboardHit())
{
/* Check what key was pressed */
nOption = TBXCliGetchRemapped();
nOption = toupper (nOption);
/* Process the key */
switch (nOption)
{
/* (T): Activate a timeslot for (T)ransmission */
case 'T':
Result = TB640FskSelectAdapterTrunkTimeslot (&un32Adapter, &un32Trunk, &un32TrunkCnt, &un32Timeslot);
if (TBX_RESULT_SUCCESS(Result))
{
TBX_UINT32 un32Protocol;
TBX_CHAR szLine [TB640_FSK_CLI_MAX_LINE_SIZE_GET];
TB640_FSK_DISPLAY_PRINT ("Select a protocol to use (0=stress): ");
szLine[0] = '\0';
fgets (szLine, TB640_FSK_CLI_MAX_LINE_SIZE_GET, stdin);
un32Protocol = atoi( szLine );
switch( un32Protocol )
{
case TB640_FSK_CUSTOM_TEST_TYPE_STRESS:
un32Protocol = TB640_FSK_CUSTOM_TEST_TYPE_STRESS;
break;
default:
un32Protocol = 0xFFFFFFFF; /* Invalid protocol */
break;
}
if( un32Protocol == 0xFFFFFFFF )
{
TB640_FSK_DISPLAY_PRINT ("Invalid protocol selected.\n");
}
else
{
while( un32TrunkCnt-- )
TB640FskAdapterTrunkTimeslotLaunchAction
(
TB640FskActivateTransmission,
un32Protocol,
un32Adapter,
un32Trunk++,
un32Timeslot
);
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY);
}
}
break;
/* (R): Activate a timeslot for (R)eception */
case 'R':
Result = TB640FskSelectAdapterTrunkTimeslot (&un32Adapter, &un32Trunk, &un32TrunkCnt, &un32Timeslot);
if (TBX_RESULT_SUCCESS(Result))
{
while( un32TrunkCnt-- )
TB640FskAdapterTrunkTimeslotLaunchAction
(
TB640FskActivateReception,
0,
un32Adapter,
un32Trunk++,
un32Timeslot
);
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY);
}
break;
/* (K)ick transmission sequence on a timeslot */
case 'K':
Result = TB640FskSelectAdapterTrunkTimeslot (&un32Adapter, &un32Trunk, &un32TrunkCnt, &un32Timeslot);
if (TBX_RESULT_SUCCESS(Result))
{
while( un32TrunkCnt-- )
TB640FskAdapterTrunkTimeslotLaunchAction
(
TB640FskKickTransmission,
0,
un32Adapter,
un32Trunk++,
un32Timeslot
);
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY);
}
break;
/* (C)lear all timeslots (return to 'idle' state) */
case 'C':
Result = TB640FskSelectAdapterTrunkTimeslot (&un32Adapter, &un32Trunk, &un32TrunkCnt, &un32Timeslot);
if (TBX_RESULT_SUCCESS(Result))
{
while( un32TrunkCnt-- )
TB640FskAdapterTrunkTimeslotLaunchAction
(
TB640FskDeactivate,
0,
un32Adapter,
un32Trunk++,
un32Timeslot
);
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY);
}
break;
/* (B)egin automatic call generation */
case 'B':
if (fAutomaticCallGenerationActivated == TBX_FALSE)
{
Result = TB640FskSelectStressParameters (&un32StressDelayBetweenCalls, &un32StressOutgoingTimeslotMinIdleMsec);
if (TBX_RESULT_SUCCESS(Result))
{
TB640_FSK_LOG (TRACE_LEVEL_4, "Starting stress testing (delay=%d, minidlemsec=%d)\n", \
un32StressDelayBetweenCalls, un32StressOutgoingTimeslotMinIdleMsec);
/* Take a new time snapshot */
un32Timer = TBX_GET_TICK();
/* Clear the statistics */
TBX_SEM_GET (g_StressStatsSem, TBX_SEM_WAIT_FOREVER);
memset ((char *)&g_StressStats, 0, sizeof(g_StressStats));
g_StressStats.un32StartTimestamp = un32Timer;
g_StressStats.un32CurrentTimestamp = un32Timer;
g_StressStats.fStatsActivated = TBX_TRUE;
TBX_SEM_GIV (g_StressStatsSem);
/* Start the test */
un32LastTimeWhereACallWasMade = un32Timer;
fAutomaticCallGenerationActivated = TBX_TRUE;
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY | TB640_FSK_CLI_FORCE_REFRESH);
}
}
else
{
TB640_FSK_DISPLAY_PRINT ("Automatic call generation is already activated....\n");
}
break;
/* (S)top automatic call generation */
case 'S':
if (fAutomaticCallGenerationActivated != TBX_FALSE)
{
TBX_SEM_GET (g_StressStatsSem, TBX_SEM_WAIT_FOREVER);
g_StressStats.fStatsActivated = TBX_FALSE;
TBX_SEM_GIV (g_StressStatsSem);
fAutomaticCallGenerationActivated = TBX_FALSE;
TB640_FSK_LOG (TRACE_LEVEL_4, "Stopped stress testing\n");
TB640_FSK_LOG (TRACE_LEVEL_4," Rx FSK messages per sec. : %08d Tx FSK messages per sec. : %08d\n",
un32NbRxFskMsgPerSeconds, un32NbTxFskMsgPerSeconds);
TB640_FSK_LOG (TRACE_LEVEL_4," Rx FSK messages total : %08d Tx FSK messages total : %08d\n",
g_StressStats.un32NbRxPackets, g_StressStats.un32NbTxPackets);
TB640_FSK_LOG (TRACE_LEVEL_4," Rx FSK ack per sec. : %08d Tx FSK ack per sec. : %08d\n",
un32NbRxFskAckPerSeconds, un32NbTxFskAckPerSeconds);
TB640_FSK_LOG (TRACE_LEVEL_4," Rx FSK ack total : %08d Tx FSK ack total : %08d\n",
g_StressStats.un32NbRxAck, g_StressStats.un32NbTxAck);
TB640_FSK_LOG (TRACE_LEVEL_4," Unexpected Rx (while Tx state): %08d Unexpected Rx (while Rx state): %08d\n",
g_StressStats.un32NbRxWhileTxState, g_StressStats.un32NbRxWhileRxState);
TB640_FSK_LOG (TRACE_LEVEL_4," Unexpected Ack (other) : %08d Unexpected FSK ack : %08d\n",
g_StressStats.un32NbUnexpectedRx, g_StressStats.un32NbUnexpectedAck);
TB640_FSK_LOG (TRACE_LEVEL_4," Rx sequences completed : %08d Tx sequences completed : %08d\n",
g_StressStats.un32NbRxSeqCompleted, g_StressStats.un32NbTxSeqCompleted);
TB640_FSK_LOG (TRACE_LEVEL_4," Tx retransmit : %08d\n",
g_StressStats.un32NbTxRetransmit);
TB640_FSK_LOG (TRACE_LEVEL_4," Rx sequences timeout : %08d Tx sequences timeout : %08d\n",
g_StressStats.un32NbRxSeqTimeout, g_StressStats.un32NbTxSeqTimeout);
TB640_FSK_LOG (TRACE_LEVEL_4," No free tmslot for stress tst : %08d Nb elapsed sec. since start : %08d\n",
g_StressStats.un32NbCallNoFreeTimeslotToSend, ((g_StressStats.un32CurrentTimestamp - g_StressStats.un32StartTimestamp) / 1000));
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY | TB640_FSK_CLI_FORCE_REFRESH);
}
else
{
TB640_FSK_DISPLAY_PRINT ("Automatic call generation is not activated....\n");
}
break;
/* Space = refresh */
case ' ':
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY | TB640_FSK_CLI_FORCE_REFRESH);
break;
/* (A)djust trace levels */
case 'A':
TB640FskAdjustTraceLevel (&g_AppContext->un32FileLogLevel, &g_AppContext->un32DisplayLogLevel);
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY);
break;
/* (P)rint timeslot history */
case 'P':
Result = TB640FskSelectAdapterTrunkTimeslot (&un32Adapter, &un32Trunk, &un32TrunkCnt, &un32Timeslot);
if (TBX_RESULT_SUCCESS(Result))
{
while( un32TrunkCnt-- )
TB640FskPrintTimeslotHistory (un32Adapter, un32Trunk++, un32Timeslot);
g_fRefreshDisplay |= (TB640_FSK_CLI_CLEAR_BEFORE_REFRESH | TB640_FSK_CLI_REFRESH_DISPLAY);
}
break;
/* Display window move down */
case '2':
TBX_SEM_GET (g_AppContext->DisplaySem, TBX_SEM_WAIT_FOREVER);
if (g_un32ErrorLineReadIndex != g_un32ErrorLineWriteIndex)
{
if (++g_un32ErrorLineReadIndex >= TB640_FSK_CLI_MAX_NB_ERROR_LINES)
{
g_un32ErrorLineReadIndex = 0;
}
}
TBX_SEM_GIV (g_AppContext->DisplaySem);
g_fRefreshDisplay |= (TB640_FSK_CLI_REFRESH_DISPLAY);
break;
/* Display window page down */
case '3':
TBX_SEM_GET (g_AppContext->DisplaySem, TBX_SEM_WAIT_FOREVER);
/* Make sure there is something in the buffer */
if (g_un32ErrorLineReadIndex != g_un32ErrorLineWriteIndex)
{
un32Tmp = g_un32ErrorLineReadIndex + 25;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -