UART + Glide not working

In the code above, when I include the Gadgeteer, with the serial port class to establish the connection and using the glide, it doesnt work. What kind of project should I really use? a Gadgeteer, or FEZ Cobra Window Application? I was able to establish connection between the reader and the FEZ Cobra using a FEZ Cobra window application (with gadgeteer namespace). I use also FEZ Cobra window application with the GUI glide. But I really cant connect the two of them. :frowning:

I just don’t get what you’re trying to do !

What does Gadgeteer have to do with anything??? Why are you trying to include Gadgeteer?

Gadgeteer doesn’t give you anything that you need. Serial handling in netmf works fine, although perhaps it may not have some aspects you want (I think it bought about the read a line at a time but that’s easy enough to code).

What is your program logic ? What is it meant to do? The way I read it is there’s 3 button actions, you click one it initialises stuff, click another one it stops stuff, and click the third and then it goes into a long running wait loop trying to read the serial port.

My approach would be that you need to disengage the card / serial actions from a button press - the button then might just start displaying the data you get, but not waiting for it. Either way a button event isn’t something you should hang around in forever, you are likely to block the GUI from responding for other actions

@ Brett -

You were right, there were three buttons. And from a thread topic that I had post, I said that reader must be initialized by pressing the init button. And by pressing the init button, it must send the proper bytes for it to be initialized so I’ll need serial port to do the read and write. That part was fine ,however, when I clicked the read button, when I try to sense if the com port is still open, it says it’s not open. :frowning: (even if I did not close it)


public static void Main()
            {
 
                string xml;
                xml = "<Glide Version=\"" + Glide.Version + "\">";
                xml += "<Window Name=\"window\" Width=\"320\" Height=\"240\" BackColor=\"dce3e7\">";
                xml += "<Button Name=\"init\" X=\"240\" Y=\"8\" Width=\"80\" Height=\"32\" Alpha=\"255\" Text=\"init\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
                xml += "<Button Name=\"btn\" X=\"4\" Y=\"202\" Width=\"80\" Height=\"32\" Alpha=\"255\" Text=\"Read\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
                xml += "<Button Name=\"stopbtn\" X=\"236\" Y=\"202\" Width=\"80\" Height=\"32\" Alpha=\"255\" Text=\"Clear\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
                xml += "<TextBox Name=\"text0\" X=\"5\" Y=\"9\" Width=\"200\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"Frequency\" X=\"10\" Y=\"102\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"Frequency:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"EPC\" X=\"10\" Y=\"73\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"EPC:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"RSSI\" X=\"10\" Y=\"130\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"RSSI(-):\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"Phase\" X=\"9\" Y=\"158\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"Phase:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBox Name=\"text1\" X=\"105\" Y=\"71\" Width=\"200\" Height=\"32\" Alpha=\"255\" Text=\" \" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"2\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBox Name=\"text2\" X=\"107\" Y=\"103\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBox Name=\"text3\" X=\"106\" Y=\"130\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBox Name=\"text4\" X=\"106\" Y=\"157\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"kHz\" X=\"215\" Y=\"104\" Width=\"50\" Height=\"32\" Alpha=\"255\" Text=\"kHz\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"dBm\" X=\"215\" Y=\"130\" Width=\"50\" Height=\"32\" Alpha=\"255\" Text=\"dBm\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"deg\" X=\"215\" Y=\"158\" Width=\"50\" Height=\"32\" Alpha=\"255\" Text=\"deg\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"4\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBlock Name=\"tagsdet\" X=\"89\" Y=\"203\" Width=\"100\" Height=\"32\" Alpha=\"255\" Text=\"Tags Detected:\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"0\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                xml += "<TextBox Name=\"text5\" X=\"199\" Y=\"200\" Width=\"35\" Height=\"32\" Alpha=\"255\" Text=\"\" TextAlign=\"Left\" TextVerticalAlign=\"Top\" Font=\"0\" FontColor=\"0\" BackColor=\"000000\" ShowBackColor=\"False\"/>";
                //    xml += "<Image Name=\"img1\" X=\"2\" Y=\"6\" Width=\"317\" Height=\"35\" Alpha=\"255\"/>";
                //   xml += "<Button Name=\"btn\" X=\"100\" Y=\"104\" Width=\"120\" Height=\"32\" Alpha=\"255\" Text=\"Read\" Font=\"4\" FontColor=\"000000\" DisabledFontColor=\"808080\" TintColor=\"000000\" TintAmount=\"0\"/>";
                xml += "</Window>";
                xml += "</Glide>";
          //      do{
                // Resize any loaded Window to the LCD's size.
                Glide.FitToScreen = true;
 
                    // Load the Window XML string.
                    window = GlideLoader.LoadWindow(xml);
 
                    // Activate touch
                    GlideTouch.Initialize();
 
                    // Initialize the window.
                    InitWin();
                    // Assigning a window to MainWindow flushes it to the screen.
                    // This also starts event handling on the window.
                    Glide.MainWindow = window;
                    Thread.Sleep(-1);
            }
           static void InitWin()
           {
                 //Initialized buttons,textblocks and textboxes
                 //checking on tap button events
           }
           static void init_TapEvent(object sender)
            {
                 //Com port opened
                 //reader initialization performed
                 //com port not closed for reading
            }
           static void read_TapEvent(object sender)
           {
                  //sense the com port if its still open (but when I sensed it, it isnt)
                  //must send the appropriate read commands
           }

OK, but still…

[quote]What does Gadgeteer have to do with anything??? Why are you trying to include Gadgeteer?
[/quote]

If we assume you don’t need Gadgeteer, then lets just get back to the core of your logic error. I personally think you will need to show ALL your code, not just snippets and your commented blocks in each handler.

First up, where is your COM port object defined? Where is it first opened? Do you have a flag or a check that confirms when you attempt to click button 3 that it is open?

PS: I have my cobra firmware updated and ready to go when you send all your code :slight_smile: