13 Replies Latest reply on Oct 3, 2017 5:43 PM by ntan

    USB  as multiple COM ports?

    honey.gupta

      Hi there, I checked the USBUART component.

         

      According to what I have understood, it lets the USB act as a COM port (which I can access via hyperterminal/putty,etc..)

         

      Suppose my application requires me to have 2 [or multiple] COM ports.

         

      Is it possible to have the USB act as multiple COM ports?

         

      Regards.

        • 1. Re: USB  as multiple COM ports?
          user_51135297
                  Hello Goose. I hope you are better. please read at: http://www.cypress.com/?app=forum&rID=66583 best regards, jesus. pd, it if you are using psoc 3,4,5 platform.   
          • 2. Re: USB  as multiple COM ports?
            user_78878863

            The question was abourt USB-UARTs (CDC ports), not about physical UARTS.

               

            I would guess that USB would support having multiple virtual COM ports over a single USB connection. For example the FT2232 supports this IIRC. But I would also guess that the default windows driver cannot handle this...

               

            Also, the USBUART component cannot handle this AFAIK, you would need to roll your own USB device driver on the PSoC side...

               

            What is your use case here? Is there a reason not to handle multiple transfers of a single COM port? (I think the useable bandwidth would also be reduced in this scenario).

            • 3. Re: USB  as multiple COM ports?
              user_51135297
                      Hi Hli. thanks for your reply and corrections. regards, jesus   
              • 4. Re: USB  as multiple COM ports?
                honey.gupta

                Hello hli, thanks for you reply......there is no particular reason for me not to use a single port for multiple transfers..

                   

                Its just that, I somehow got to know that using USB as multiple COM ports is infact possible in PSoC. So I just wanted to try it out.

                   

                However, I dont think it can be done by mere use of the APIs.

                   

                So I was just looking for a clue as to how to go through with it? [just to increase my PSoC knowledge]

                   

                 

                   

                Regards.

                • 5. Re: USB  as multiple COM ports?
                  honey.gupta
                          Any update on this ......anyone? Regards.   
                  • 6. Re: USB  as multiple COM ports?
                    honey.gupta

                    Hi there, I got to know that to actually achieve this [just incase anyone needs to...], one would require some changes to be made in the attached file........some application-level changes.

                    • 7. Re: USB  as multiple COM ports?
                      vikas.sewani

                      Hi Goose,

                         

                      I am attempting to do the same. Could you advise me on how I can do this?

                         

                       

                         

                      Many thanks,

                         

                      G

                      • 8. Re: USB  as multiple COM ports?
                        user_202566985

                        hello

                        I have created a composite device with two COM ports.

                        One COM port is operating correctly but the other COM port is not working properly...

                        Where should I fix it?

                        pic.png

                        • 9. Re: USB  as multiple COM ports?
                          ntan

                          It seems that there is an API function USBUART_GetComPort(void) to select one of two COM ports.  Following snapshot comes from the USBUART component datasheet.

                          GS003274.png

                          Actually, I didn't use this API function.  Can you try this API function?

                           

                          Regards,

                          Noriaki

                          • 10. Re: USB  as multiple COM ports?
                            user_202566985

                            thank you for your reply.

                            I described SetComPort for each EP interrupt in USBUART_1_episr.c

                            For the time being, the program is working as intended.

                            Is this the correct way?

                            • 11. Re: USB  as multiple COM ports?
                              ntan

                              You don't need to modify the episr file.  Just call USBUART_SetComPort() before calling port associated APIs.  I have modified the project attached to this discussion as follows.

                               

                                 for(;;)
                                 {
                                      // the number of bytes        
                                      USBUART_SetComPort(USBUART_COM_PORT1);
                                      Count = USBUART_GetCount();
                                      
                                      if(Count != 0){
                                          //Get data
                                          USBUART_SetComPort(USBUART_COM_PORT1);
                                          USBUART_GetAll(Buffer);
                              
                              
                                          if(Buffer[0] == '?'){
                                              // Send data
                                              USBUART_SetComPort(USBUART_COM_PORT2);
                                              USBUART_PutData(Hello, Count2);
                                              //wait tx
                                              USBUART_SetComPort(USBUART_COM_PORT2);
                                              while(!USBUART_CDCIsReady()){}
                                          }else{
                                              // Echo data
                                              USBUART_SetComPort(USBUART_COM_PORT1);
                                              USBUART_PutData(Buffer, Count);
                                              //wait tx
                                              USBUART_SetComPort(USBUART_COM_PORT1);
                                              while(!USBUART_CDCIsReady()){}
                                          }
                                      }
                                  }
                              

                               

                              And the execution result as follows.

                              GS003277.png

                              At the end of for-loop you called USBUART_DataIsReady() API function to wait for TX completed.  But the API is incorrect.  USBUART_CDCIsReady is used to wait for the TX completion.

                               

                              Attached project is modified for the CY8CKIT-059 without using the external crystal oscillator.

                               

                              Regards,

                              Noriaki

                              • 12. Re: USB  as multiple COM ports?
                                user_202566985

                                Thank you for your kindness.

                                We will provide a project for SetComPort in USBUART_1_episr.c for reference only.

                                 

                                And the execution result as follows.

                                test.png

                                The attached project file was created with CY8C5868AXI-LP035.

                                • 13. Re: USB  as multiple COM ports?
                                  ntan

                                  Please let me add a comment.

                                   

                                  It is recommended to use a MACRO CALLBACK feature to add your own code to the ISR procedure.  You can declare a CALLBACK in the "cyapicallbacks.h" header file like as follows to be invoked from the ISR .

                                   

                                  #ifndef CYAPICALLBACKS_H
                                  #define CYAPICALLBACKS_H
                                      
                                  
                                      /*Define your macro callbacks here */
                                      /*For more information, refer to the Writing Code topic in the PSoC Creator Help.*/
                                      #define USBUART_1_EP_1_ISR_ENTRY_CALLBACK
                                      extern void USBUART_1_EP_1_ISR_EntryCallback(void);
                                      
                                      #define USBUART_1_EP_2_ISR_ENTRY_CALLBACK
                                      extern void USBUART_1_EP_2_ISR_EntryCallback(void);
                                  
                                      
                                  #endif /* CYAPICALLBACKS_H */   
                                  

                                   

                                  The callback function can be described in any C files like main.c

                                   

                                  void USBUART_1_EP_1_ISR_EntryCallback(void) {
                                      USBUART_1_SetComPort(0);
                                  }
                                  
                                  void USBUART_1_EP_2_ISR_EntryCallback(void) {
                                      USBUART_1_SetComPort(0);
                                  }
                                  

                                   

                                  This feature was implemented in PSoC Creator 3.3  You don't need to modify the "Generated_Source" files anymore when using the CALLBACK feature.

                                   

                                  Regards,

                                  Noriaki