cycletime可选,优化显示
This commit is contained in:
parent
8479266ba2
commit
1970f178fd
@ -43,7 +43,7 @@
|
|||||||
#define NSEC_PER_SEC 1000000000
|
#define NSEC_PER_SEC 1000000000
|
||||||
#define EC_TIMEOUTMON 500
|
#define EC_TIMEOUTMON 500
|
||||||
#define TEST_STEP_CYCLETIME (500 * 1000) // us
|
#define TEST_STEP_CYCLETIME (500 * 1000) // us
|
||||||
#define INPUT_CHECK_TIMEOUT (10 * 1000) // us
|
#define INPUT_CHECK_TIMEOUT (5 * 1000) // us
|
||||||
#define MAX_SLAVE 8
|
#define MAX_SLAVE 8
|
||||||
|
|
||||||
#define ROL_U16(a, n) ((uint16_t)((a) << (n) | (a) >> (16 - n)))
|
#define ROL_U16(a, n) ((uint16_t)((a) << (n) | (a) >> (16 - n)))
|
||||||
@ -58,7 +58,7 @@
|
|||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* 擦除行, 输出 */ \
|
/* 擦除行, 输出 */ \
|
||||||
sprintf(err.str + strlen(err.str), CSI_START "K" fmt, ##__VA_ARGS__); \
|
sprintf(err.str + strlen(err.str), CSI_START "2K" fmt, ##__VA_ARGS__); \
|
||||||
err.cnt++; \
|
err.cnt++; \
|
||||||
err.is_showed = false; \
|
err.is_showed = false; \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -84,6 +84,7 @@ pthread_t thread1, thread2;
|
|||||||
struct timeval tv, t1, t2;
|
struct timeval tv, t1, t2;
|
||||||
int32_t dorun = 0;
|
int32_t dorun = 0;
|
||||||
int32_t test_step = 0;
|
int32_t test_step = 0;
|
||||||
|
int32_t test_cycle = 0;
|
||||||
int deltat, tmax = 0;
|
int deltat, tmax = 0;
|
||||||
int64 toff, gl_delta;
|
int64 toff, gl_delta;
|
||||||
int DCdiff;
|
int DCdiff;
|
||||||
@ -95,6 +96,7 @@ int expectedWKC;
|
|||||||
volatile int wkc;
|
volatile int wkc;
|
||||||
boolean inOP;
|
boolean inOP;
|
||||||
uint8 currentgroup = 0;
|
uint8 currentgroup = 0;
|
||||||
|
static int cycletime;
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
@ -206,7 +208,7 @@ static void show_check(void)
|
|||||||
err.is_showed = true;
|
err.is_showed = true;
|
||||||
}
|
}
|
||||||
printf("ID | Type | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |\n"
|
printf("ID | Type | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |\n"
|
||||||
"---+------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+\n");
|
"---+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+\n");
|
||||||
for (int i = 1; i <= ec_slavecount; i++)
|
for (int i = 1; i <= ec_slavecount; i++)
|
||||||
{
|
{
|
||||||
char buff[512];
|
char buff[512];
|
||||||
@ -244,7 +246,7 @@ static void show_check(void)
|
|||||||
p += sprintf(p, " | | | | | | | |");
|
p += sprintf(p, " | | | | | | | |");
|
||||||
}
|
}
|
||||||
// show diff
|
// show diff
|
||||||
p += sprintf(p, "\n | Diff |");
|
p += sprintf(p, "\n |Diff/ms|");
|
||||||
j = 0;
|
j = 0;
|
||||||
for (; j < io_test[i].input_bytes; j++)
|
for (; j < io_test[i].input_bytes; j++)
|
||||||
{
|
{
|
||||||
@ -267,7 +269,7 @@ static void show_check(void)
|
|||||||
p += sprintf(p, " | | | | | | | |");
|
p += sprintf(p, " | | | | | | | |");
|
||||||
}
|
}
|
||||||
// show max
|
// show max
|
||||||
p += sprintf(p, "\n | Max |");
|
p += sprintf(p, "\n | Max/ms|");
|
||||||
j = 0;
|
j = 0;
|
||||||
for (; j < io_test[i].input_bytes; j++)
|
for (; j < io_test[i].input_bytes; j++)
|
||||||
{
|
{
|
||||||
@ -307,12 +309,12 @@ static void show_check(void)
|
|||||||
{
|
{
|
||||||
p += sprintf(p, " | | | | | | | |");
|
p += sprintf(p, " | | | | | | | |");
|
||||||
}
|
}
|
||||||
p += sprintf(p, "\n---+------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+\n");
|
p += sprintf(p, "\n---+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+\n");
|
||||||
printf("%s", buff);
|
printf("%s", buff);
|
||||||
}
|
}
|
||||||
printf("Processdata cycle %5d, test step %3d, Wck %3d, DCtime %12" PRId64 ", dt %6" PRId64 "ns\n",
|
printf("Processdata cycle %5d, cycletime %dus, Wck %3d, DCtime %12" PRId64 "ns, dt " CSI_START "K" /*擦除到行尾*/ "%6" PRId64 "ns\n",
|
||||||
dorun, test_step, wkc, ec_DCtime, gl_delta);
|
dorun, cycletime, wkc, ec_DCtime, gl_delta);
|
||||||
printf("Error count %lu " SET_COLOR(F_B_RED, "(Press 'q' to exit)\n"), err.cnt);
|
printf("Test cycle %d, Test step %3d, Error count %lu " SET_COLOR(F_B_RED, "(Press 'q' to exit)\n"), test_cycle, test_step, err.cnt);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
osal_usleep(50000);
|
osal_usleep(50000);
|
||||||
@ -511,6 +513,7 @@ static void write_output(void)
|
|||||||
if (list_idx >= ARRAY_SIZE(test_list))
|
if (list_idx >= ARRAY_SIZE(test_list))
|
||||||
{
|
{
|
||||||
list_idx = 0;
|
list_idx = 0;
|
||||||
|
test_cycle++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ec_timet current_time = osal_current_time();
|
ec_timet current_time = osal_current_time();
|
||||||
@ -657,27 +660,29 @@ OSAL_THREAD_FUNC ecatcheck(void *ptr)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ctime;
|
cycletime = 50;
|
||||||
|
|
||||||
printf("SOEM (Simple Open EtherCAT Master)\nIO test for TJ30-XXXX\n");
|
printf("SOEM (Simple Open EtherCAT Master)\nIO test for TJ30-XXXX\n");
|
||||||
|
switch (argc)
|
||||||
if (argc == 3)
|
|
||||||
{
|
{
|
||||||
|
case 3:
|
||||||
|
cycletime = atoi(argv[2]);
|
||||||
|
[[fallthrough]];
|
||||||
|
case 2:
|
||||||
dorun = 0;
|
dorun = 0;
|
||||||
ctime = atoi(argv[2]);
|
|
||||||
|
|
||||||
/* create RT thread */
|
/* create RT thread */
|
||||||
osal_thread_create_rt(&thread1, stack64k * 2, &ecatthread, (void *)&ctime);
|
osal_thread_create_rt(&thread1, stack64k * 2, &ecatthread, (void *)&cycletime);
|
||||||
|
|
||||||
/* create thread to handle slave error handling in OP */
|
/* create thread to handle slave error handling in OP */
|
||||||
osal_thread_create(&thread2, stack64k * 4, &ecatcheck, NULL);
|
osal_thread_create(&thread2, stack64k * 4, &ecatcheck, NULL);
|
||||||
|
|
||||||
/* start acyclic part */
|
/* start acyclic part */
|
||||||
tj30_test(argv[1]);
|
tj30_test(argv[1]);
|
||||||
}
|
break;
|
||||||
else
|
default:
|
||||||
{
|
printf("Usage: tj30_test ifname [cycletime]\n"
|
||||||
printf("Usage: red_test ifname1 cycletime\nifname = eth0 for example\ncycletime in us\n");
|
"ifname = eth0 for example\n"
|
||||||
|
"cycletime in us(default is 50us)\n");
|
||||||
|
|
||||||
ec_adaptert *adapter = NULL;
|
ec_adaptert *adapter = NULL;
|
||||||
printf("\nAvailable adapters:\n");
|
printf("\nAvailable adapters:\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user