加入test error count ,fix set_bit / clr_bit

This commit is contained in:
Chinky 2024-01-14 15:43:04 +08:00
parent 1970f178fd
commit 2fabd78466
1 changed files with 49 additions and 18 deletions

View File

@ -51,16 +51,16 @@
#define GET_BIT(value, bit) (((value) >> (bit)) & 1) // 读取指定位
#define CPL_BIT(value, bit) ((value) ^= (1 << (bit))) // 取反指定位
#define SET_BIT(value, bit) ((value) &= ~(1 << (bit))) // 把某个位置0
#define CLR_BIT(value, bit) ((value) |= (1 << (bit))) // 把某个位置1
#define CLR_BIT(value, bit) ((value) &= ~(1 << (bit))) // 把某个位置0
#define SET_BIT(value, bit) ((value) |= (1 << (bit))) // 把某个位置1
#define show_err(fmt, ...) \
do \
{ \
/* 擦除行, 输出 */ \
sprintf(err.str + strlen(err.str), CSI_START "2K" fmt, ##__VA_ARGS__); \
err.cnt++; \
err.is_showed = false; \
#define show_err(fmt, ...) \
do \
{ \
/* 擦除行, 输出 */ \
sprintf(ec_error.str + strlen(ec_error.str), CSI_START "2K" fmt, ##__VA_ARGS__); \
ec_error.cnt++; \
ec_error.is_showed = false; \
} while (0)
#define time_cmp(a, b, CMP) \
@ -103,7 +103,7 @@ static struct
char str[1024];
size_t cnt;
bool is_showed;
} err;
} ec_error;
typedef struct
{
@ -118,6 +118,7 @@ typedef struct
ec_timet max_in_out_time_diff[32];
bool error[32];
size_t err_cnt[32];
} io_test_t;
io_test_t io_test[MAX_SLAVE + 1] = {0};
@ -180,7 +181,7 @@ static void show_check(void)
char ch;
bool is_first = true;
err.is_showed = true;
ec_error.is_showed = true;
for (;;)
{
// 按 'q` 键退出
@ -195,17 +196,17 @@ static void show_check(void)
}
else
{
printf(CSI_START "4F"); // 光标上移2行,到行首
printf(CSI_START "4F"); // 光标上移4行,到行首
for (int i = 1; i <= ec_slavecount; i++)
{
printf(CSI_START "4F"); // 光标上移4行,到行首
printf(CSI_START "5F"); // 光标上移5行,到行首
}
}
if (!err.is_showed)
if (!ec_error.is_showed)
{
printf("%s", err.str); // 输出
err.str[0] = '\0';
err.is_showed = true;
printf("%s", ec_error.str); // 输出
ec_error.str[0] = '\0';
ec_error.is_showed = true;
}
printf("ID | Type | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |\n"
"---+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+\n");
@ -309,12 +310,40 @@ static void show_check(void)
{
p += sprintf(p, " | | | | | | | |");
}
// err_cnt
p += sprintf(p, "\n |ErrCnt |");
j = 0;
for (; j < io_test[i].input_bytes; j++)
{
for (int k = 0; k < 8; k++)
{
int idx = j * 8 + k;
if (io_test[i].err_cnt[idx] == 0)
{
p += sprintf(p, " 0");
}
else if (io_test[i].err_cnt[idx] > 999)
{
p += sprintf(p, SET_COLOR(B_YELLOW, "999+"));
}
else
{
p += sprintf(p, SET_COLOR(B_YELLOW, " %3lu"), io_test[i].err_cnt[idx]);
}
p += sprintf(p, "|");
}
}
for (; j < 2; j++)
{
p += sprintf(p, " | | | | | | | |");
}
p += sprintf(p, "\n---+-------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+\n");
printf("%s", buff);
}
printf("Processdata cycle %5d, cycletime %dus, Wck %3d, DCtime %12" PRId64 "ns, dt " CSI_START "K" /*擦除到行尾*/ "%6" PRId64 "ns\n",
dorun, cycletime, wkc, ec_DCtime, gl_delta);
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);
printf("Test cycle %d, Test step %3d, Error count %lu " SET_COLOR(F_B_RED, "(Press 'q' to exit)\n"), test_cycle, test_step, ec_error.cnt);
fflush(stdout);
osal_usleep(50000);
@ -478,6 +507,8 @@ static void check_io()
if (time_cmp(&io_test[i].check_stop_time[idx], &current_time, <)) // 到期
{
io_test[i].error[idx] = true;
io_test[i].err_cnt[idx]++;
CLR_BIT(io_test[i].is_changed[j], k);
}
}
else