Right! I've been putting this off

One of my products on the market is a “Crane Datalogger” written in C and runs on a SBC386… All was well until you need to download it " RS232 and approx 1meg file size " VERY SLOOOOW. So I am porting it to a Panda with a 1 - 2 gig SD card… The trouble is I cannot get a reliable serial link… I have tried and tried to get a suitable / stable connection from the Panda to… well anything!!! I heave read numerous posts and it seems that as I’m an embedded engineer, my approach is wrong…William seems to be the best person to help on this…

We have a SLI (Safe Load Indicator) that spills out a maximum of 33 bytes at a time… I process this data, then store on the SD… When a PC is connected I have a program to upload all the storage ( MB’s ) to the PC… This will be high speed using USB, The connection to the SLI HAS to be RS232…

Gus tells me to create a thread, to deal with the serial buffer.

Struggling… Any help would be a boon.

Cheers Ian

When you get to a full application and you run into problems, no one (not you not us) can easily guess what is going wrong.

Serial is very simple so why not keep that it that way? Where is the “simple” code you are suing to read/send data?

What is you application going to do? Read 1meg of data and save on SD card?

No. The SLI sends 33 byte’s of normal crane data (load, angle, radius etc…)

On the PIC I set up an interrupt and move each char into a circular buffer (about twice the size required ) When a END (0x3E) control character is received there must be a START (0x3C) control character -34 bytes down the buffer… I know I have a complete packet…Check the CRC and budder bing I’m done… With NETMF however… I read 1… 2… 3… maybe even 4 bytes at a time before the interrupt fires…

When you say I need a separate thread to read the entire receive buffer… I really don’t know where to start (never done multi threading before, never needed to)

Is there a way to ensure an interrupt after each character? That will make it a lot easier to understand… I always assumed if you specify a receive buffer length, that’s when the interrupt fires, but this is not the case…

Sending to the PC is a breeze with NETMF via the USB, this is why I need to do this as most laptops don’t have RS232 any more.

Cheers Ian

Sorry I didn’t quite answer all your questions… Reading SD and send to PC no problem… There are a few examples to do this…

Its just receiving the 33 byte’s on the serial port… I send time, date and config packets fine. I would just like to say to the Panda " get me 33 bytes rom the serial port and tell me when your done ", " If there’s a problem let me know ".

SPI and I2C are an absolute pleasure to program in NETMF, but Asyncronous data different ball game.

Maybe this is where you got lost I think, you can’t program NETMF system like you do on PIC. You need to start thinking fresh on how to utilize the NETMF system not how to convert C-PIC-code to C#-FEZ-code. Why do you need an interrupt on every byte for example? You only need this if you are thinking “PIC”.

Your code should be similar to GPS http://www.tinyclr.com/downloads/Extension/FEZ_Extensions_GPS.cs

Look how there is a 200 byte buffer that we read inside the interrupt event… And then we start reading one byte at a time.

Now, the GPS driver is made to work with many other things. Your driver can be made better and much easier. You know exactly what your application needs so you can teak the whole system to your advantage. I suggest you run a thread that keep reading the UART info a buffer, lets say it is 200 bytes. Then you go in a loop reading each byte individually like you do on your PIC. When a packet is found then you can pass on the packet to other part of your application where this maybe used.
A good example on this is the Wii driver http://www.tinyclr.com/downloads/Component/FEZ_Components_Wii.cs
It does exactly what I just explained, it used I2C not UART bot the concept is there.

=============
I hope this will help you achieve what you want :slight_smile:

Excellent!! This is exactly what I’m after…

I think using VB6 has softened my programming! MSCOMM is very high level and doesn’t give you much to think about in an event driven environment…

I know it’s a totally different way to program and I told you it would take me a few months to get on top of it…

I’ll keep you posted Gus…

Thanks Ian

Gus… Still trying to get this topic jogging on…

Can you tell me why the SerialPort class is throwing an unreferenced error.


using System.IO.Ports;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace datalogger
{
    public static partial class FEZ_Extensions
    {
        static public class GPS
        {
            static char[] split_char = new char[] { ',' };
            static string[] sentence_fields;
            static char[] time_utc = new char[8];
            static Serialport _port;                   // <- unreferenced
            static byte[] buffer = new byte[200];
            static bool _data_is_valid;
            private static GPSStateMachine gps_decoder_state;
            static char[] pree_buffer = new char[10];
            static char[] pree = { 'G', 'P', 'R', 'M', 'C' };
            static int pree_index = 0;
            static char[] sentence = new char[200];
            static char[] GPRMC_sentence_array = new char[200];
            static int GPRMC_sentence_array_length = 0;
            static int sentence_index = 0;

I’ve included the “microsoft.SPOT.Hardware.SerialPort” in the references, but can’t include it .


using Microsoft.SPOT.Hardware.Serialport;       //<-not recognised

I’m just using the emulator for now so there’s no firmware problem

Cheers Ian

Never mind… I had just pasted your example into my project and didn’t notice that the ‘P’ in “SerialPort” should have been upper-case not lower-case as per the example…

Sometimes I’m stupid right down to the core!!

Cheers Ian

What happens if you add all assemblies listed here FAQ – GHI Electronics

See “What assemblies (libraries) do I need to add to my project?”

Like I said its ok now… I’ve now done about 5 new projects using the Panda and Cobra… It was just a typo…

Just on a side note! Who do I speak to about commercial quantities of the 100 pin USBizi.

I am drawing up my board VERY soon and I need to get my pricing right.

Cheers Ian

You can email/call GHI directly about volumes.