Testing MS/TP on Windows.

This commit is contained in:
skarg
2007-06-29 23:11:57 +00:00
parent 1824d4a95e
commit 17eb5d9789
2 changed files with 14 additions and 33 deletions
+10 -33
View File
@@ -346,19 +346,6 @@ void npdu_handler(
fprintf(stderr, "NPDU: received PDU!\n"); fprintf(stderr, "NPDU: received PDU!\n");
} }
static void test_transmit_task(void *pArg)
{
while (TRUE) {
Sleep(1000);
MSTP_Create_And_Send_Frame(
&MSTP_Port,
FRAME_TYPE_TEST_REQUEST,
MSTP_Port.SourceAddress,
MSTP_Port.This_Station,
NULL, 0);
}
}
/* returns a delta timestamp */ /* returns a delta timestamp */
uint32_t timestamp_ms(void) uint32_t timestamp_ms(void)
{ {
@@ -377,27 +364,9 @@ uint32_t timestamp_ms(void)
static void test_millisecond_task(void *pArg) static void test_millisecond_task(void *pArg)
{ {
DWORD ticks = 0;
DWORD last_ticks = GetTickCount();
DWORD total_ticks = 0;
(void)SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); (void)SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
while (TRUE) { for (;;) {
ticks = GetTickCount(); dlmstp_millisecond_timer();
if (ticks > last_ticks) {
total_ticks = ticks - last_ticks;
} else if (ticks == last_ticks) {
Sleep(1);
continue;
} else {
/* integer rollover */
total_ticks = (MAXDWORD - last_ticks) + ticks;
}
while (total_ticks) {
dlmstp_millisecond_timer();
total_ticks--;
}
last_ticks = ticks;
Sleep(1); Sleep(1);
} }
} }
@@ -425,6 +394,14 @@ int main(void)
} }
/* forever task */ /* forever task */
for (;;) { for (;;) {
#if 0
MSTP_Create_And_Send_Frame(
&MSTP_Port,
FRAME_TYPE_TEST_REQUEST,
MSTP_Port.SourceAddress,
MSTP_Port.This_Station,
NULL, 0);
#endif
Sleep(10000); Sleep(10000);
} }
+4
View File
@@ -453,6 +453,10 @@ void MSTP_Receive_Frame_FSM(volatile struct mstp_port_struct_t *mstp_port)
/* BadCRC */ /* BadCRC */
/* indicate that an error has occurred during the reception of a frame */ /* indicate that an error has occurred during the reception of a frame */
mstp_port->ReceivedInvalidFrame = true; mstp_port->ReceivedInvalidFrame = true;
#if PRINT_ENABLED_RECEIVE_DATA
fprintf(stderr, "MS/TP: Rx Header-BadCRC %02X!\n",
mstp_port->DataRegister);
#endif
/* wait for the start of the next frame. */ /* wait for the start of the next frame. */
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
} else { } else {