WP7608 -- RS232 Communication problems

Hi:

Legato version:
18.03.0_b463e04cf08fb8d8f1ea5ee00d7894c0

question :
Through RS232 sent to WP76 development board, received the first message is scrambled or missing

Thank you for your reply.

WP8548(18.06.4_a2b118ed13919cebd20f9d71e8810748_modified) no problem.

Do you mean the first character is missing?
You can try my code see if this fixed the issue:

#define TIMER_INTERVAL_SEC 1
#define TIMER_INTERVAL_uSEC 100000
static void tmrHandler(le_timer_Ref_t timerRef) {
	 //LE_INFO("INSIDE TIMER");
	 tcflow(fd1,TCION );

}
COMPONENT_INIT
{






		LE_INFO("UART_TCP_DEMO");
#if 1
		fd1=OpenPort("/dev/ttyHS0");



		le_clk_Time_t clk = { .sec = TIMER_INTERVAL_SEC, .usec = TIMER_INTERVAL_uSEC };
		    le_timer_Ref_t adxlPollingTimer = le_timer_Create("ADXL_TIMER");
		    le_timer_SetRepeat(adxlPollingTimer, 1000);
		    le_timer_SetInterval(adxlPollingTimer, clk);
		    le_timer_SetHandler(adxlPollingTimer, tmrHandler);
		    le_timer_Start(adxlPollingTimer);

Thank you for your reply.

Your code is incomplete. Here’s my code.

#include “rs232.h”
#include “LEDLightUpComponent.h”
#include “CloudIF_VendOut.h”

int fd;
struct termios opt;
char rs232readbuf[MSG_LEN_MAX] = {0};

#if 1
static tty_Speed_t SpeedTestTable[*] =
{
LE_TTY_SPEED_0,
LE_TTY_SPEED_50,
LE_TTY_SPEED_75,
LE_TTY_SPEED_110,
LE_TTY_SPEED_134,
LE_TTY_SPEED_150,
LE_TTY_SPEED_200,
LE_TTY_SPEED_300,
LE_TTY_SPEED_600,
LE_TTY_SPEED_1200,
LE_TTY_SPEED_1800,
LE_TTY_SPEED_2400,
LE_TTY_SPEED_4800,
LE_TTY_SPEED_9600,
LE_TTY_SPEED_19200,
LE_TTY_SPEED_38400,
LE_TTY_SPEED_57600,
LE_TTY_SPEED_115200,
LE_TTY_SPEED_230400,
LE_TTY_SPEED_460800,
LE_TTY_SPEED_500000,
LE_TTY_SPEED_576000,
LE_TTY_SPEED_921600,
LE_TTY_SPEED_1000000,
LE_TTY_SPEED_1152000,
LE_TTY_SPEED_1500000,
LE_TTY_SPEED_2000000,
LE_TTY_SPEED_2500000,
LE_TTY_SPEED_3000000,
LE_TTY_SPEED_3500000,
LE_TTY_SPEED_4000000,
};
#endif

static void* read_thread(void* context)
{
char buf[1024];
ssize_t read_NUM = 0;

memset(buf, 0, sizeof(buf));

while(1)
{
	read_NUM = read(fd, buf, sizeof(buf));
	if(read_NUM > 0)
	{
		printf("Windows: %s\n", buf);

		strncpy(rs232readbuf, buf, strlen(buf));
		if(rs232readbuf[0] == '{')
		{
			check_VendOut(rs232readbuf);
		}
		//rs232_LEDbuf(rs232readbuf);
	}

	memset(buf, 0, sizeof(buf));
}

return NULL;

}

int open_init(void)
{
le_thread_Ref_t readThreadPtr;

fd = le_tty_Open("/dev/ttyHS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
	perror("open /dev/ttyHS0: ");
}

le_tty_SetBaudRate(fd, SpeedTestTable[17]); //17
le_tty_SetFraming(fd, 'N', 8, 1);
le_tty_SetFlowControl(fd, LE_TTY_FLOW_CONTROL_NONE);
le_tty_SetRaw(fd, 2048, 0);

readThreadPtr = le_thread_Create("read_thread", read_thread, NULL);
le_thread_Start(readThreadPtr);

return fd;

}

you don’t need to have my full code.
my idea is to start a periodic timer and call the tcflow(fd1,TCION ) every second.

indent preformatted text by 4 spaces

Jan 6 00:04:31 | rs232_wp76[2329]/rs232_wp76_exe T=main | _main.c main() 60 | == Starting Event Processing Loop ==
Jan 6 00:04:31 | rs232_wp76[2329]/RS232_wp76Component T=main | RS232_wp76Component.c _RS232_wp76Component_COMPONENT_INIT() 50 | UART_TCP_DEMO
Jan 6 00:04:31 | rs232_wp76[2329]/framework Preformatted textT=main | LE_FILENAME le_tty_Open() 247 | Serial device ‘/dev/ttyHS0’ acquired by pid 2329.
Jan 6 00:04:31 | rs232_wp76[2329]/framework T=main | LE_FILENAME le_timer_Start() 1260 | threadRecPtr->timerFD=9

I don’t see any useful information.
I suspect WP76’s wake-up call has something to do with it, but I don’t know how to investigate it.

I thought you are having same problem as this topic:

thank you.
I take a look.

hi @taojiafu,
do you need more information on this topic?
best regards,

I suspect wp76 is in sleep mode, but I don’t know how to turn it off.

That is why in my workaround, i need to set up a timer to wake up uart

Can I set it without AT instruction?

What do you mean by AT instruction?

Hi,

In order to prevent the WP76 module to enter sleep mode then you need to acquire a wakeup source in your application:

If you want to turn off the whole power suspend mechanism (for testing) then you can use this command:

echo off > /sys/power/autosleep

BR
Jay