FEZ panda II: help please! having trouble communicating between frameworks using serial ports

Hello, I am new with the FEZ panda, and netmf, but I am very familiar with C# as I am a computer scientist.

I am currently using a .NET framework program to create a user interface which communicates with the FEZ panda II through com ports. When i deploy the program in debug mode and open COM1 on the hardware, the PC .NET4.0 framework doesn’t say that there are any com ports available.

Also, I am told that a com port should open when I connect the Panda to my computer, however, the only port that opens (sometimes) is COM3 which is label as a bootloader interface.

Does anyone know whats wrong??

Thanks in advance!!

On the pc?! You mean the emulator?

I think you are confusing the com ports of the device with the ports on your pc?

Right, but I guess my question is: how do i access the com ports on my device from the PC side? or vice versa? also are there any programs that allow you to monitor said com ports?

thanks!

oh, I see. you are trying to transfer data from the device to your PC…

The device is just like another PC. The software you run inside the device controls the ports on the device itself and has nothing to do with your development machine, your dev machine is only sued to debug the software on the device and that is the only connection point.

To transfer data, you need some sort of connection that you use to transfer data, could be an ethernet port, serial port or USB.

The easiest one is by using the RS232 shield, or better, if you have the Panda ultimate kit then you already have usb2serial eblock that you can use with FEZ Connect shield.

ah i see… Actually, my program seems to be a bit a of a unique case… The project will always be connected to the PC, and will always be run in debug mode through visual studio. Also, I only really need to be able to send data from the PC to the Panda, and not the other way around. With this criteria is it possible just to use the USB connection the panda comes with to transfer data? or do i need more components?

Right now, all the program really controls is about 10 electric solenoids that are either set to high or low, so i should be able to run everything through debug mode for these stages of the project, correct?.

thanks in advance!

Yes using USB is possible but more advanced and I am not how comfortable you are with FEZ just yet. Take a look at CDC or at debug+CDC options.

Ah yes CDC… I had previously seen code snippets of this in the online user PDFs but never tried to implement one due to the lack of documentation. The code snippet shows how to write to a CDC on the hardware side, but it does not convey how to properly read it in on PC side. is there an example or documentation for that?

Thanks!

Did you look at CDC class in documented? It is explained in full details and with needed drivers!

Here is a link but please always refer to documentation http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/93fcfa03-228b-cbe4-e8a5-9a7a8f36cdf0.htm

“reading it on the PC side” is relatively simple. Open a terminal program, say Tera Term that you use to upgrade the Fez, and then connect to the relevant port. Out comes any data that you send from the Fez.

If you look at the very cool project Fez Term, you might find exactly what you want. [url]http://wiki.tinyclr.com/index.php?title=FezTerm[/url]

It strange… when I connect to the teraTerm and try to set up a new serial port, there aren’t any available. I have however tried to use the CDC drivers to communicate through USBClient. The only problem is, everything goes insane when I try to run the sample program for CDC. the CDC port opens fine on COM4, but then basically reboots the FEZ into a state where my computer cant recognize it, and therefore cant communicate with it, and I end up having to reinstall the drivers for the Panda and reupdate the firmware.

I think CDC might be the best bet i have because its the only method ive used that is successfully opening a a virtual COM port on my computer.

for now, the messages im sending only need to go one way - from the pc NET4.0 program across the miniusb that the panda comes with, and then read by the NETMF code on the hardware side.

thanks,

My very first recommendation was to use RS232 shield :slight_smile: CDC works fine but it has many little things that you should be aware of, like deploying or resetting the device while the port is open on the PC will cause many problems, sometimes PC freeze or BSOD! On top of all this, you are doing debug+CDC, which also works well, but any mistake (unexpected behavior) can confuse windows.

You can buy a shield, very cheap, or make your own RS232 circuits for about $1. I am not trying to sell you anything, just providing suggestions to make it all go smother for your first trial with custom USB control.

If you think things go haywire when in CDC mode then I would bet you don’t have the drivers working properly. Check Device Manager for unknown devices, and try an alternate USB cable, and see if there’s any evidence of what to do next. Or as Gus says, go to a shield or DIY at leatst to prove the concept.

You are correct, it does confuse windows when i start the cdc with debugging, and then stop debugging the program. Is there a way to exit/stop the cdc safely?

Or is it such that when the instance that the CDC lives in dies, it exits and the port closes?

What did device manager show?

There are good code examples out there on CDC, search them out. Remember that most of this is USB specific - if the USB controller on the PC side doesn’t “see” the new device and the driver doesn’t link to it, then you can get into a “lost” state.

okay so i’ve been working, and i can now get the program to open up a virtual COM4 when i:

USBC_CDC cdc = USBClientController.StandardDevices.StartCDC_WithDebugging();

however, when i see the COM port open up in the device manager, i can see that my “debuggable .NET framework device” is now gone. I’m assuming this is because it’s trying to turn the same usb port the Panda is using into a virtual serial port, and therefore overrides the debuggable interface.

it is also noted when i execute the line of code i posted above in debug mode, the code basically times out. I am attributing this also to the fact that i think the newly configured COM port is overriding the debug interface.

How can I make it so that it opens up the com port as well as still being able to debug?

Have you loaded the special driver for cdc + debugging?

yes indeed! before i loaded the special driver, it wouldn’t open up the com port properly when i started the CDC debugger. now it opens up COM4 and recognizes it as a virtual serial port. the debuggable interface however, disappears :frowning:

AHA! okay so ive made a lot of progress with the board. I’m using the CDC with debuggable interface. I notice that when it starts the CDC, it opens up COM4 on my pc side, and then there is an unrecognized USBizi device. where are the drivers for that device??

thanks in advance,

I am new to micro framework and I have been ask to design a high speed serial logger. So I start with panda II. When receiving I am missing some of the RX data. My data packet is 92 bytes long and I am getting 32 packets in 1 second and I have 3 of these channels coming to the system at same time.

My simple code as follows
public static void Comm2_Thread()
{
SerialPort UART = new SerialPort(“COM4”, 57600);
byte[] rx_byte = new byte[2000];
int read_count = 0;
UART.Open();

        while (true)
        {
            Debug.GC(false);
            // Thread.Sleep(1000);
           
            read_count = UART.Read(rx_byte, 0, 2000);
            string pk1 = "";

            if (read_count > 0)// do we have data?
            {
                int xx_cou = 0;
                while (xx_cou < read_count)
                {




                    try
                    {
                        byte[] a1 = new byte[1];
                        a1[0] = rx_byte[xx_cou];
                        string a2 = new     string((Encoding.UTF8.GetChars(a1)));

                        pk1 = pk1 + a2;
                    }
                    catch { }
   


                    xx_cou = xx_cou + 1;
                }



            }
            Debug.Print("--------------------------------------------------------------------");
            Debug.Print("COM4  " + pk1);
        }  
    }

I am getting overlap of packets in 256th to ~ 266th byte, but next 1744 is perfect. My first thought was my TX data stream too fast and I set to transmit only 2 packets per second but error is still there. Then I try to get only first 200 bytes at a time but in some times I get few data missing in the middle. I know at the moment I am not synchronize the incoming data but it should not be a problem when I am interested in reading the buffer.

Sample of incoming data
0.07798058_A,000,001.09,-001.70,M,+344.22,+021.01,00,+0.0001,+0.0002,+0.0004,+0.0004,-50.00C,
Packet overlapping due to error
0.1786935_Y,360,236.25,-025.23,M,+F,090,002.10,+005.67,M,-345.21,+021.01,02,+0.0001,+0.0002,+0.0004,+0.0004,-45.21C,

Am I expecting too much from Panda II or I am missing some thing?
I really need a solution quickly
Thanks
:’(