UART information

Hi,
Thanks in advance if you could help…

Would like to know how could i write the codes for passing information using UART ?

Firstly, it will be an array of hexadecimal something like {0xFF 0xFF 0x010 x04 0x03 0x05 0x02 0xF1}
Second, it will be on an FEZ panda II board.
third, how do i use the function in UART ? as in i write to the program ?

im stuck in writing this codes as the visual basic kept reporting errors while i type the line of hexadecimal.

here is part of my codes.

using System;
using System.IO.Ports;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;


namespace MFConsoleApplication1
{
    public class Program
    {
        public static void Main()
        {
            OutputPort LED;
            InputPort Button;

            SerialPort UART = new SerialPort("COM1", 115200);
            //int read_count = 0;
            byte[] tx_data;
            byte[] rx_data = new byte[10];
            byte trans[10] ={0xFF 0xFF 0x010 x04 0x03 0x05 0x02 0xF1};
            UART.ReadTimeout = 0;
            UART.Open();
            // flush all data
            UART.Flush();

            LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, false);
            Button = new InputPort((Cpu.Pin)FEZ_Pin.Digital.An3,true,Port.ResistorMode.PullDown);

            while (true)
            {
                LED.Write(Button.Read());
                Thread.Sleep(10);

                
                // send some data
                UART.Write();

            }
        }
    }
}

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

The code you have posted is C# not Visual Basic.

@ ceyao - You are missing commas between the hex values

It should be


byte trans[10] ={0xFF, 0xFF, 0x010, x04, 0x03, 0x05, 0x02, 0xF1};

@ ceyao - Actually, there is several things wrong with your byte declaration, here is the correct declaration:

byte[] trans = new byte[10] {0xFF, 0xFF, 0x01, 0x04, 0x03, 0x05, 0x02, 0xF1, 0x00, 0x00};

You also were requesting 10 bytes in your declaration while only passing in 8 byte values. You need to have a value to send over UART instead of calling a blank Write() function. Lastly, you are claiming that you are attempting to develop for the Panda II using Visual Basic, which is not possible because NETMF support for Visual Basic did not come around until NETMF 4.2 where as the last supported NETMF for Panda II is 4.1, so it is not possible to use VB to develop for the Panda II.

Hi James,

thnaks for your detailed reply.
Would like to clarifiy, correct me if im wrong. As previously, i had this friend, he was using the same micro-contoller, FEZ panda 2 where he used VB to develop the panda 2 board and integrated with Mircrsof kinect sensor. It could run smoothly with the communication with the sensor and able to evulate the motion it sense.

therefore i assume i would also be able to do so using VB to develop the panda 2.
Pandon me, as i do not have the codes with me currently. therefore, could not refer to the NETMF version that im currently using. Would check it and revert back. Thanks for the help with the codes.

Cheers.

No, that is unlikely to have happened in the past. Your friend might have used VB to create the PC based application, but not the Fez side of things.

You aren’t getting Visual Studio, the development environment itself, confused with the language by any chance are you? C# is the current language you’ll need to use for Netmf 4.1 that Panda II and family work with. You can use Visual C# Express 2010 or if you like you can use Visual Studio and develop C# code; both of those work. If you’re using Visual Studio you could create Visual Basic apps for the PC.

Hi Brett,

I had check the system that is running on would be as what you had mention. Thanks for the clarification on VB and C#.