Serial Pass through possible or testing technique

I am using the G120E with a teridian power measurement chip, anyway, its a serial interface(uart). This chip has desktop app to test its functionality and set parameters. Is it possible to pass through this serial data to my desktop as a comport?

It seems feasible and but trying to understand how and if i could do this. Or is their a better technique?

@ anthonys - Use CDC.

Thats awesome! Do i use the same cable i use to program it? mmm…if its in cdc mode…how do get it back into notmal mode to program it?

Now…this a feature which dramatically improves my ability to test peripherals…

@ anthonys - Check section 6 page 10 in the following link, basically you can prevent your application program from running (LDR0 / LDR1) or set the debug port to be the COM1 port with the Mode pin.

Maybe i explained myself wrong…will this allow me to communicate with chip connected to the COM3 on G120E? Essentially being able to test each comport device isolated from the other parts?

@ anthonys - With a bit of programming you will be able to do that. You can use your USB port for either programming or as CDC. It will depend based on the state of MODE pin.

Forward data received from the CDC link to your desired COM port once you detect that CDC mode is activated.

I have some experimenting to do, any code some one can share or suggest? I have found this

Just to confirm, i will set the mode PIN HIGH only during powerup then its in COM mode, then my code should act different by detecting this state, how do i detect this state?

@ anthonys - In Visual Studio the properties page, select the .NET Micro Framework, you will see a the Transport = Serial, and Device = COMx which is connected to COM1 of your G120E device. Where x is the a free COM port on you PC. You only need to do this and set the Mode pin “High” if you need a debugger attached.

I don’t think you need to detect the state, you must reserve COM1 for when you connect a debugger. Did you want to share COM1 with a peripheral device and debugger?

@ PHITEK - I think you are wrong.

@ anthonys - In Visual Studio the properties page, select the .NET Micro Framework, you will see a the Transport = Serial, and Device = COMx which is connected to COM1 of your G120E device.[/quote]
Well, you will see nothing. Unless you do the following:

  1. Set MODE pin high.
  2. Connect TX and RX pins of COM1 to USB-to-UART module and plug that module to your PC.

No, without setting MODE pin high, you won’t be able to use CDC.

Simplest way would be by using an [em]InputPort[/em].

It is a good starting point, but many things have changed and that code will not work with latest SDK.
You should check:

  1. [url][/url] → CDC
  2. [em]GHI.Processor.DebugInterface[/em] (only available in the latest SDK)
1 Like

@ PHITEK - I have not read your first reply (you was too quick to delete it), but I have read your second reply. I have just checked and I can confirm that you won’t be able to use CDC without asserting MODE pin. I have used Mouse and CDC examples from [url][/url].

I am not sure how you have managed to change USB port’s functionality in the runtime.

@ iamin - I don’t have a G120E platform so I would not be able to test this or help any further, sorry.

ANyone guide me on how to get COM Mode working? I am holding MODE pin to HIGH as i press the reset button. How do i know its in COM mode?

Also, how do i install the drivers? I have downloaded CDC_Driver.inf into C:\Program Files (x86)\GHI Electronics\USB Drivers\NETMF Interface as suggested but i do not see any COM port in the device manager or WINUSB…what am i doing wrong?

Using the G120E BTW

@ anthonys - The only way to tell if the board is in serial debug mode is to keep MODE in the correct state indefinitely and read it in your application. If you use the default parameters for the USB Client CDC class and are using the 2016 R1 Pre-Release 1 SDK, the driver should be installed under C:\Program Files (x86)\GHI Electronics\USB Drivers\CDC Interface. Windows will automatically recognize the device when it is plugged in and install this driver.

@ John - So i will make the mode pin HIGH indefinitely.

What will i see in device manager to know its in this state?

It definitely in another state because the USB properties of the project no longer recognize the G120E, will it come up with a COM port no?

When i goto Transport -> Select -> Serial…the Device part shows COM6…but when i disconnect the G10E, the device still shows COM6 so not sure if its the default port on my laptop(my laptop doesn’t have any serial port anyway).

@ anthonys - When MODE is high, the device is in serial debug mode. In order to debug the device, you must connect your computer to COM1 on the board.

To communicate with your application over USB, you must use the GHI.Usb.Client.Cdc class and connect your computer to the USB debug port on the board. If you are using 2016 R1 Pre-Release 1 and the parameterless constructor on the Cdc class, Windows will automatically recognize the device and create a COM port for it called “GHI CDC Interface”.

Are you using the G120E SoM in your own product or are you using it on one of our boards?

@ John - So in normal MODE, i use GHI.Usb.Client.Cdc class to communicate to my computer using the USB debug port?

I have a metering chip on COM3 and want to interact with it directly through the USB debug port. Hence i i should use the CDC class?

I think serial debug mode is useless in my case? Why is the point of serial debug anyway?

Any know why i get this error?

            // Start Cdc
            Cdc vsp = new Cdc();
            Controller.ActiveDevice = vsp;  //ERROR An unhandled exception of type 'System.InvalidOperationException' occurred in GHI.Usb.dll  

            // Send "Hello world!" to PC every second. (Append a new line too)
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes("Hello world!\r\n");
            while (true)
                // Check if connected to PC
                if (Controller.State != UsbController.PortState.Running)
                    Debug.Print("Waiting to connect to PC...");
                    vsp.Stream.Write(bytes, 0, bytes.Length);

@ anthonys - Serial debug is used when you need to use the USB port in your application for something like, like acting as a storage drive, keyboard, mouse, or others.

If you want to communicate over the USB port, you need to be in serial debug mode and use the CDC class. You still need to write the code that maps the data sent and received from the CDC class to COM3.

For your error, are you in serial debug mode when you get the exception?

OK…starting to understand it…

I have put my g120e in serial debug mode, and have added the cdc code. Question, according to the code…i should get the Hello World being sent to my computer, should a com port appear in device manager?

Appreciate your patience!