For double check ,
which do you need ,“Read procedure” or “Write Procedure” of UART pins?
On top of this thread,you asked how to “Read” pin state but it seems that you and jyijyi are talking about “Write Procedure” of UART pins.
I have tried to set DTR as input GPIO by “echo in > /sys/class/gpio/gpio101/direction”, after that it can read the pin status by "cat /sys/class/gpio/gpio101/value ".
Is it possible that they can read these pin state with your suggested ways(GPIO) while they use UART as 8-wire UART(such as enabling Hardware flow control) ?
In this case, the customer will not control RTS,CTS,DSR and DTR manually as GPIO by “echo/cat”.
you need to first send an AT command: AT!RIOWNER=1
after that you can control the RI in linux console:
echo RI > /sys/class/gpio/export
echo in > /sys/class/gpio/gpioRI/direction
cat /sys/class/gpio/gpioRI/value
In addition, I found that you can read the RTS pin status by AT command:
AT!entercnd=“A710”
AT!bsgpio?6
For setting the CTS pin, you can use ioctl():
int arg;
if (ioctl(fd1, TIOCMGET, &arg) == -1)
{
LE_DEBUG("ERROR: %s", strerror(errno));
}
if (level)
arg |= TIOCM_RTS;
else
arg &= ~TIOCM_RTS;
if (ioctl(fd1, TIOCMSET, &arg) == -1) {
LE_DEBUG("ERROR: %s", strerror(errno));
}
Since I’m a little bit confusing, please provide your answer for my question first.
Is it possible that they can read these pin state with your suggested ways(GPIO) while they use UART as 8-wire UART(such as enabling Hardware flow control) ?
In this case, the customer will not control RTS,CTS,DSR and DTR manually as GPIO by “echo/cat”.
>In addition, I found that you can read the RTS pin status by AT command:
>AT!entercnd=“A710”
>AT!bsgpio?6
The customer needs to read UART pins via Linux, not external host.
So, AT commands is not useful.
For setting the CTS pin, you can use ioctl():
I copied you suggestion in my source code as follows. test_helloComponent.c (1.6 KB)
Then, following error was happened.
/root/legato/workspace/test_hello/test_helloComponent/test_helloComponent.c:30:18: error: ‘fd1’ undeclared (first use in this function)
You did not call open(fd,) with serial port dev name so it did not work.
When you enabled hardware flow control, you need to check “RTS” and “CTS” not “DTR” or others.
If we set unique GPIO numbers with each UART pins then we can use specified function of these pins by UART block, not GPIO control(echo) , I think this solution should be acceptable for the customer.
BTW, regarding to GPIO numbers of each pins,such as DTR is #17, how can I find this HW connection information >
I can not find such information in any document.
I think it is necessary for the customer.
In order to call open(), we need to set device name in dev.
What is the device name of UART1?
If you don’t want echo/cat to control gpio, you can use legato goio api.
For the gpio number document, i don’t have either, but i think now you have all the information to control dtr dcd dsr.
The device name for uart1 is /dev/ttyHS0 after setting AT! mapuart=17,1 and reboot.
I realized that WP76 could do UART communication with RTS/CTS hardware flow control with ioctl().
And I realized that WP76 could not read DTR, DCD, RI, DSR with ioctl()
To summarize discussion, I think how to check them the following.
Is it correct?
I think the best way to check all 8-wire UART’s pins with just one command.
It means I want to avoid mixing some type commands(echo/) on a program, if possible.
Which command is the best way?
Then, how should I write program?
Could you provide information about legato gpio api?
I hope it is a simple solution because I didn’t know it in detail