Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

deepaksrma
Copy link
Contributor

  • add new TCs to test UART rxavailable, txready and txempty APIs.

Signed-off-by: Deepak sharma [email protected]

@tizen-build
Copy link

Target : [76177faf3303154c2f3bd04e9a2b7f2782da9088] - Code Rule Check OK.

Copy link
Contributor

@jeongchanKim jeongchanKim left a 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.

@tizen-build
Copy link

Target : [73fbdc8c349651c513a4d7a1ea782cb9f73ab3cf] - Code Rule Check OK.

@deepaksrma deepaksrma changed the title apps/testcase/systemio/itc: add new UART TCs [do not merge]apps/testcase/systemio/itc: add new UART TCs Jul 12, 2021
@tizen-build
Copy link

Target : [cb8df92dc393026b806f82950f50cdc69db9d0d4] - Code Rule Check OK.

@tizen-build
Copy link

Target : [d12a0c61879e5ad09bd12d7b54b8a109d8474f56] - Code Rule Check OK.

@sunghan-chang
Copy link
Contributor

@deepaksrma Please let me know the plan of this PR.

@deepaksrma
Copy link
Contributor Author

@deepaksrma Please let me know the plan of this PR.

will update this after the merging of following PR :
#5101

lib/libc/termios/lib_tccheckfifo.c Outdated Show resolved Hide resolved
os/include/termios.h Outdated Show resolved Hide resolved
- 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]>
@tizen-build
Copy link

Target : [23a21a7] - Code Rule Check OK.

@deepaksrma deepaksrma changed the title [do not merge]apps/testcase/systemio/itc: add new UART TCs apps/testcase/systemio/itc: add new UART TCs Sep 7, 2021
Comment on lines +178 to +179
static bool g_tc_rxavailable;
static bool g_tc_rxavailable_res; // used to hold the result of rxavailable TC
Copy link
Contributor

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.

Copy link
Contributor Author

@deepaksrma deepaksrma Sep 8, 2021

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)

Comment on lines +946 to +947
/* itc_systemio_iotbus_uart_txready();
itc_systemio_iotbus_uart_txempty();
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mistakenly added, will uncomment

Comment on lines +576 to +590
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. How about other boards like imxrt? Does it return invalid or not supported or already impleneted?
  2. Are they only used in the tc for coverage? Then let's cover them with TC config.

Copy link
Contributor Author

@deepaksrma deepaksrma Sep 8, 2021

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

Comment on lines +577 to +581
g_tc_rxavailable = 1;
g_tc_rxavailable_res = 0;
rtl8721d_up_send(dev, 'a');
sleep(1);
ret = g_tc_rxavailable_res;
Copy link
Contributor

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?

Copy link
Contributor Author

@deepaksrma deepaksrma Sep 8, 2021

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.

Copy link
Contributor Author

@deepaksrma deepaksrma Sep 8, 2021

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I understand they are "begin" and "end" of tc to get valid data. Am I right?
  2. It's the loopback test. There is no way to get another data. Why do you need begin and end?
  3. 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.

Copy link
Contributor

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;

Copy link
Contributor

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);

Copy link
Contributor Author

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;

Copy link
Contributor

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();
Copy link
Contributor

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;
Copy link
Contributor

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.

Comment on lines +577 to +581
g_tc_rxavailable = 1;
g_tc_rxavailable_res = 0;
rtl8721d_up_send(dev, 'a');
sleep(1);
ret = g_tc_rxavailable_res;
Copy link
Contributor

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;

Comment on lines +577 to +581
g_tc_rxavailable = 1;
g_tc_rxavailable_res = 0;
rtl8721d_up_send(dev, 'a');
sleep(1);
ret = g_tc_rxavailable_res;
Copy link
Contributor

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);

@sunghan-chang
Copy link
Contributor

@sangam-swami Could you manage this PR?

@tizen-build
Copy link

Target : [23a21a7] - Code Rule Check OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants