-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apps/testcase/systemio/itc: add new UART TCs #5050
base: master
Are you sure you want to change the base?
Conversation
Target : [76177faf3303154c2f3bd04e9a2b7f2782da9088] - Code Rule Check OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split the commit as 2.
1st is for changing the framework and lib, 2nd is for tc.
Target : [73fbdc8c349651c513a4d7a1ea782cb9f73ab3cf] - Code Rule Check OK. |
Target : [cb8df92dc393026b806f82950f50cdc69db9d0d4] - Code Rule Check OK. |
Target : [d12a0c61879e5ad09bd12d7b54b8a109d8474f56] - Code Rule Check OK. |
@deepaksrma Please let me know the plan of this PR. |
will update this after the merging of following PR : |
- add new APIs in iotbus to test UART TCs, APIs are: iotbus_uart_rxavailable() iotbus_uart_txready() iotbus_uart_txempty() - add new TCs to test UART rxavailable, txready and txempty APIs. Signed-off-by: Deepak Sharma <[email protected]>
- add new TCs to test UART rxavailable, txready and txempty APIs. Signed-off-by: Deepak Sharma <[email protected]>
Target : [23a21a7] - Code Rule Check OK. |
static bool g_tc_rxavailable; | ||
static bool g_tc_rxavailable_res; // used to hold the result of rxavailable TC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree adding codes here for tc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check my comment below and let me know what you think?
#5050 (comment)
/* itc_systemio_iotbus_uart_txready(); | ||
itc_systemio_iotbus_uart_txempty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you comment them out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mistakenly added, will uncomment
case TIOCS_AVAIL: | ||
g_tc_rxavailable = 1; | ||
g_tc_rxavailable_res = 0; | ||
rtl8721d_up_send(dev, 'a'); | ||
sleep(1); | ||
ret = g_tc_rxavailable_res; | ||
break; | ||
|
||
case TIOCS_READY: | ||
ret = rtl8721d_up_txready(dev); | ||
break; | ||
|
||
case TIOCS_EMPTY: | ||
ret = rtl8721d_up_txempty(dev); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- How about other boards like imxrt? Does it return invalid or not supported or already impleneted?
- Are they only used in the tc for coverage? Then let's cover them with TC config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add this in other boards after finalizing for this board
g_tc_rxavailable = 1; | ||
g_tc_rxavailable_res = 0; | ||
rtl8721d_up_send(dev, 'a'); | ||
sleep(1); | ||
ret = g_tc_rxavailable_res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what you want to do. Could you leave comment to explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for rxavailable TC, my approach is:
- rxavailable returns true when there is data in rx fifo and when data comes on the tx line in loopback mode then it enables the RxIrq and it goes to uart_recvchars(), where it checks whether data is available in rx fifo or not.
- so to check the data in rx fifo, we need to send the data first, which we have sent through rtl8721d_up_send() and before sending the data we need to enable the g_tc_rxavailable so that g_tc_rxavailable_res can collect the result for our sent data and when it collects the result then immediately turn off the g_tc_rxavailable, which means it won't collect the result further.
please let me know what you think about this approach.
I'll add the comments once we agree on the approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kishore-sn @sangam-swami @jeongchanKim please review this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I understand they are "begin" and "end" of tc to get valid data. Am I right?
- It's the loopback test. There is no way to get another data. Why do you need begin and end?
- Even it's loopback mode, sender and receiver should be implemented using existed APIs without more variables. If it's impossible, it means our APIs are not enough to use serial functionality. Then we should add them as public API, not tc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing this implementation as follows:
Remove all global variables.
case TIOCS_AVAIL:
rtl8721d_up_send(dev, 'a');
sleep(1);
ret = rtl8721d_up_rxavailable(dev);
break;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, I think we can change it further to make the code much cleaner.
In the driver we do:
case TIOCS_AVAIL:
ret = rtl8721d_up_rxavailable(dev);
break;
In the test case file we do:
iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
ret = iotbus_uart_control_loopback(h_uart, LOOPBACK_ON);
ret = iotbus_uart_write(h_uart, sz_input_text, sizeof(sz_input_text));
ret = iotbus_uart_rxavailable(h_uart);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can not do like this:
case TIOCS_AVAIL:
rtl8721d_up_send(dev, 'a');
sleep(1);
ret = rtl8721d_up_rxavailable(dev);
break;
because when we sent the data in loopback mode then it comes on the RX FIFO immediately and generates the interrupt,
and calls uart_recvchars() where it checks whether data is available in RX FIFO or not, if data is available then it removes the data from RX FIFO and copies it to buffer so the following lines won't work, because when it comes to rtl8721d_up_rxavailable(), then data is not in RX FIFO because it has been transferred to buffer.
ret = rtl8721d_up_rxavailable(dev);
break;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
Then we need to keep a global variable. But its better to keep a single global variable and protect it with a semaphore. Add a new ioctl to reset global variable.
bool g_rxavail' 'sem_t g_rxavail_sem
TCIOC_RXAVAIL_RESET:
take g_rxavail_sem
g_rxavail = false
give g_rxavail_sem
TCIOC_RXAVAIL:
take g_rxavail_sem
ret = g_rxavail;
give g_rxavail_sem
And in rtl8721d_up_rxavailable()
take g_rxavail_sem
g_rxavail = ret;
give g_rxavail_sem
@@ -865,6 +942,10 @@ int itc_uart_main(void) | |||
itc_systemio_iotbus_uart_set_mode_write_read_p(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a "TODO" comment for line 939
//itc_systemio_iotbus_uart_write_read_flush_read_p();// TASH being hanged on execution of the testcase
If this particular testcase is not resolved and is left to be resolved later.
@@ -175,6 +175,8 @@ | |||
*/ | |||
|
|||
static serial_t* sdrv[MAX_UART_INDEX + 1] = {NULL, NULL, NULL, NULL, NULL}; //uart 0~3, uart2 is configured as log uart | |||
static bool g_tc_rxavailable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining the meaning of this variable.
g_tc_rxavailable = 1; | ||
g_tc_rxavailable_res = 0; | ||
rtl8721d_up_send(dev, 'a'); | ||
sleep(1); | ||
ret = g_tc_rxavailable_res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing this implementation as follows:
Remove all global variables.
case TIOCS_AVAIL:
rtl8721d_up_send(dev, 'a');
sleep(1);
ret = rtl8721d_up_rxavailable(dev);
break;
g_tc_rxavailable = 1; | ||
g_tc_rxavailable_res = 0; | ||
rtl8721d_up_send(dev, 'a'); | ||
sleep(1); | ||
ret = g_tc_rxavailable_res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, I think we can change it further to make the code much cleaner.
In the driver we do:
case TIOCS_AVAIL:
ret = rtl8721d_up_rxavailable(dev);
break;
In the test case file we do:
iotbus_uart_context_h h_uart = iotbus_uart_init(DEVPATH);
ret = iotbus_uart_control_loopback(h_uart, LOOPBACK_ON);
ret = iotbus_uart_write(h_uart, sz_input_text, sizeof(sz_input_text));
ret = iotbus_uart_rxavailable(h_uart);
@sangam-swami Could you manage this PR? |
Target : [23a21a7] - Code Rule Check OK. |
Signed-off-by: Deepak sharma [email protected]