USART ASYNC - QISEND - io_wtrite

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi!

I'm just started study embedded development and have a lot of doubts.
Until now, I'm doing some stuffs and reading de docs references and books.

I have a problem with communication from my modem Quectel MC60 to AWS on QISEND command.
I'm using MCU Microchip ATSAMD21G18.
I have a buffer that does not have a fixed length. Thus I have to use QISEND without length.

My problem is the Crtl+Z using io_write function throght async process.
When I send the buffer for the server with fixed length works fine. But when I send whitouth length the io_write function does not recognize the 0x1A(Crtl+Z) and 0x1B(ESC).

All AT commands are working fine, my problem is the QISEND and the CRTL+Z

Any help will be appreciated.
Thanks and sorry, I'm a newbie in embeded development.
 

Below a piece of code:

 

struct io_descriptor *io;

usart_async_get_io_descriptor(&USART_0, &io);

// NO SUCCESS

io_write(io, "AT+QISEND\r\n" ,11);

delay_ms(2000);

io_write(io, "TEST", 4);

delay_ms(2000);

io_write(io, 0x1A, sizeof(0x1A));

delay_ms(2000);

io_write(io, 0x1B, sizeof(0x1B));

 

 

// NO SUCCESS

io_write(io, "AT+QISEND\r\n" ,11);

delay_ms(2000);

io_write(io, "TEST0x1A0x1B", 6);

 

Please help!!!! kkkk
Thanks!

 

 

Adriano

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

adriano.ferreira wrote:

io_write(io, 0x1A, sizeof(0x1A));

I assume you are trying to send a single byte with value 0x1a.

What the above will do is send 4 bytes (sizeof(0x1a) on platform with 32bit int) starting from address 0x1a.

That's not going to work. You should be getting lots of compiler warnings when building this code.

 

There might be a simpler function provided (don't know, never used Atmel Start) for sending a single byte.

Or sticking with the io_write function, I would expect any of the following to work

 

uint8_t c = 0x1a;
io_write(io, &c, 1);

io_write(io, "\x1A", 1); //hex escape
io_write(io, "\032", 1); //octal escape

EDIT to add

 

For things like

io_write(io, "TEST0x1A0x1B", 6);

 

You need to escape the 0x1a and 0x1b, so this should work

io_write(io, "TEST\x1A\x1B", 6);

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
io_write(io, 0x1A, sizeof(0x1A));

the 2nd arg points to the data, you would have to write

uint8_t c = 0x1A;
io_write(io, &c, 1);

This

io_write(io, "TEST0x1A0x1B", 6);

is not the correct syntax for hex escape in a string, it should be

io_write(io, "TEST\x1A\x1B", 6);

Edit: too late, at least we agree on what the problems are.

/Lars

Last Edited: Sat. Jun 22, 2019 - 07:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hangaround and Raving Lunatic, thank you very much for the response.

I also tried before 
 

io_write(io, 0x1a, 1);

This worked fine

uint8_t c = 0x1a;
io_write(io, &c, 1);

Again, thank you very much.
I have a lot to study and the information saved my life.

God Bless You
 

Adriano