MQX - K70 how to use USB CDC ACM device in PPP connection with web server ...

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX - K70 how to use USB CDC ACM device in PPP connection with web server ...

2,436 Views
Baerchen
Contributor II

Hi,

I want to use the USB CDC ACM class implementation in conjunction with the embedded web server. The provided example (MQX shell) shows how to use a real UART to do this. How can I interface the USB device to the embedded web server?

Thank you - Frank

Tags (3)
0 Kudos
Reply
7 Replies

1,526 Views
LuisCasado
NXP Employee
NXP Employee

Hello,

You couldn't need to write a new driver but use the pipe driver. Pipe is an standard driver in MQX, check MQXIOUG.pdf

In some part of the application Init code or first Task, install and open the pipe driver:

MQX_FILE_PTR virtualtty;

        if (IO_OK != _io_pipe_install("virtualtty:", 4, 0)) {

                              printf("Error opening virtualtty\n");

               }

              

               if (NULL == (virtualtty = fopen("virtualtty:", NULL))) {

                              printf("Error opening the driver");

               }

The Virtual_Com_App Task() will have to send the data from pipe to USB (if data available) and write USB received data to pipe.

               write(virtualtty, &g_curr_recv_buf[i], 1);                                                              //Write to pipe

               g_send_size = read(virtualtty, g_curr_send_buf, DATA_BUFF_SIZE);              //read from pipe

In parallel, the other tasks will be able to make read/write operations in the pipe (virtualtty) like real tty.

One additional thing, read from pipe is a blocking operation, you will have to use ioctl to know the pipe status.

I hope this helps, I don't have a working example.

Regards,

Luis

1,526 Views
Baerchen
Contributor II

Hi Luis,

I finally tried your proposed solution and it worked right away. Thank you again. One more problem I need to resolve is how to get the PPP device to use the created pipe driver?

I think I need actually to create two pipe drivers, one for incoming messages and the other for outgoing messages. The USB device puts its received data content in the one pipe driver (writing) and reads data from the other pipe driver to send to the host.

How to connect the two pipes to the PPP device?

Thank you - Frank

0 Kudos
Reply

1,526 Views
LuisCasado
NXP Employee
NXP Employee

Hi Frank,

I don't think you can connect two pipes to PPP protocol without modifications of the RTCS to use one pipe to receive and other pipe to send data.

Luis

0 Kudos
Reply

1,526 Views
Baerchen
Contributor II

Hi Luis,

good advice! I will try your suggested approach.

Thank you - Frank

0 Kudos
Reply

1,526 Views
matthewkendall
Contributor V

Be careful with the example task. It calls Virtual_Com_App() in an infinite loop without blocking, effectively turning the interrupt driven CDC driver into a polled one.

0 Kudos
Reply

1,526 Views
Baerchen
Contributor II

Hi Matthew,

thank you for your advice!

Frank

0 Kudos
Reply

1,526 Views
matthewkendall
Contributor V

If I have understood your question correctly, you are looking for the USB CDC implementation to offer you a formatted IO interface, so you can fopen(), fread(), fwrite(), etc., as with the UARTs.

The provided implementation does not do this. All you get is some (fairly poor) example code showing how to interface directly with the low-level API provided by the CDC driver to make an echoing device.

You will need to write an IO driver on top of the CDC driver. The best starting point is Freescale AN3902 "How to Develop I/O Drivers for MQX". I have done it. It was about 300 LOC (including comments, etc.).

0 Kudos
Reply