UART flow control with WP7608

Hi jyijyi

I’m trying to use ioctl by following procedure.

1.Make “Hello world” sample app in Developer studio
2.Modify .c source code like following one.

test_helloComponent.c (1.4 KB)

3.Build and install my app.

In order to check UART on mangOH green, which interface in /dev should I set? Currently, I set "ttyHS0" but it seems not to work.

Thank you.

–TAK

BTW, my environment is follows.

root@swi-mdm9x28-wp:~# cm info
Device: WP7605
IMEI: 353532100002653
IMEISV: 5
FSN: 2A904570501003
Firmware Version: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
Bootloader Version: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
MCU Version:
PRI Part Number (PN): 9908705
PRI Revision: 002.005
Carrier PRI Name: GENERIC
Carrier PRI Revision: 002.041_003
SKU: 1104208
Last Reset Cause: Power Down
Resets Count: Expected: 22 Unexpected: 0

root@swi-mdm9x28-wp:~# legato version
18.10.3_0b50331a9f4d0ecc0fd816c2a1300436_modified

ati3
Manufacturer: Sierra Wireless, Incorporated
Model: WP7605
Revision: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
IMEI: 353532100002653
IMEI SV: 5
FSN: 2A904570501003
+GCAP: +CGSM

OK

ati8
Legato Ver: 18.10.3_0b50331a9f4d0ecc0fd816c2a1300436_modified
Yocto Ver: SWI9X07Y_02.25.02.01 2019-01-30_09:57:36
OS Ver: Linux version 3.18.122 (jenkins@jenkins) (gcc version 6.2.0 (GCC) ) #2 9
LK Ver: SWI9X07Y_02.25.02.01
RootFS Ver: SWI9X07Y_02.25.02.01 2019-01-30_09:57:36
UserFS Ver: unknown
MCU Ver: unknown

OK

Tanoue-san (@tanoue )

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’d like to know your goal.

Thank you.

–TAK

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 ".

HI jyijyi

Thanks for your comment.
I tried you point as follows but permission error was happened.

root@swi-mdm9x28-wp:~# echo 101 > /sys/class/gpio/export
sh: write error: Operation not permitted

Then, I tried following but still error was happened.
(Refered to here: GPIO Permission Denied - Raspberry Pi Forums)

root@swi-mdm9x28-wp:~# echo “1” |sudo tee /sys/class/gpio/export
-sh: sudo: not found

Could you tell me how to set this one?

Thank you.

–TAK

please see the history above.
You need to update the yocto image on top of R12:
https://drive.google.com/file/d/1yv3ohNyaj0jFPH3JsyjDZfUgBXPJlB2w/view?usp=sharing

Hi jyijyi

Got it!
It works as follows.

—Write operation

root@swi-mdm9x28-wp:~# echo 101 > /sys/class/gpio/export
root@swi-mdm9x28-wp:~# echo out > /sys/class/gpio/gpio101/direction

root@swi-mdm9x28-wp:~# echo 1 > /sys/class/gpio/gpio101/value
=> Measured #11 pin of CN600 then it was 1.8V

root@swi-mdm9x28-wp:~# echo 0 > /sys/class/gpio/gpio101/value
=> Measured #11 pin of CN600 then it was 0V

—Read Operaiton
root@swi-mdm9x28-wp:~# echo in > /sys/class/gpio/gpio101/direction
root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio101/value
1

=>Connect #11 pin to GND(There is on CN1500)
root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio101/value
0

Thank you.

–TAK

Hi, ijyijy

What about following?

In order to check UART on mangOH green, which interface in /dev should I set? >Currently, I set “ttyHS0” but it seems not to work.

In some case, the customer needs to use ioctl so I’d like to know it.

Thank you.

–TAK

does customer accept to use GPIO as workaround?
I tried ioctl() to read the status of DTR/DSR/DCD, it is not working either.

Goto-san (@TAK_G )

I need “Read procedure” and “Write Procedure” of UART pins.

My goal is to check hardware check on our board with loopback wiring.

In summary, (using as DCE)
Read pin : RTS, DTR, DCD, RI, TxD
Write pin : CTS, DSR, RxD

BR,
Tanoue

Hi jyijyi,

First of all,I’d like to ask simple question.

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”.

Thank you.

–TAK

To set RI pin as input pin:

  1. you need to first send an AT command: AT!RIOWNER=1
  2. 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));
	      }

Hi jyijyi,

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.

Thank you.

–TAK

For your code, Of course you need to call open() before ioctl().

For entering AT command in legato application, you can send AT command through /dev/ttyAT port inside the application to get the result.

For the first question, I have tried controlling dtr dsr dcd ri via console (gpio) during uart communication with hardware flow control.

Hi jyijyi

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?

Thank you.

–TAK

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.

Hi jyijyi,

The customer original question is follows.

We don’t know GPIO number of “CTS” and “RTS”.

@Tanoue

Your original comment is follows so we should focus for it.

Thank you.

–TAK

As said before, you can use ioctl() to write CTS pin and use AT command to read RTS pin.

Hi, TAK_G

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.

image

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

BR,
Tanoue

The easiest way is to access the gpio path directly inside your legato application:

 #define INPUT_GPIO  101
 char temp_Str[256];
	  int fd;
	  char  value[10];


 memset(temp_Str,0,sizeof(temp_Str));
	  sprintf(temp_Str,"/sys/class/gpio/gpio%d/direction",INPUT_GPIO);
	   fd = open(temp_Str, O_WRONLY);
	   if (fd < 0)
	   {
	      LE_DEBUG("Failed to open gpio%d direction\n",INPUT_GPIO);
	      return;
	   }
	   else
	   {
	      LE_DEBUG("gpio%d direction opened\n",INPUT_GPIO);
	   }
	   write(fd, "in",2);
	   close(fd);

	   memset(temp_Str,0,sizeof(temp_Str));
	   sprintf(temp_Str,"/sys/class/gpio/gpio%d/value",INPUT_GPIO);
	   fd = open(temp_Str, O_RDONLY);
	   	   if (fd < 0)
	   	   {
	   	      LE_DEBUG("Failed to open gpio%d value\n",INPUT_GPIO);
	   	      return;
	   	   }
	   	   else
	   	   {
	   	      LE_DEBUG("gpio%d value opened\n",INPUT_GPIO);
	   	   }
	   	   read(fd, value,sizeof(value));
	   	   close(fd);