Hello,
I have a problem with the display of measurements, which I get through UART.
When my Spider motherboard is connected to the laptop via USB, the current value is shown on the display.
Now if you take the USB connection and connects an external power supply to the DP module, I no longer see value on display.
I tried different Code.
I’ve even programmed a small sample for testing. The Dips on Spider Mainboard are all off. I tried it on Serial Debug. Its the same. Any Idea?
using System;
using System.Collections;
using System.Threading;
using System.IO.Ports;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp10
{
public partial class Program
{
Text text;
Canvas layout;
Window window;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
SetupUI();
Debug.Print("Program Started");
GT.Socket socket = GT.Socket.GetSocket(4, true, null, null);
GT.Interfaces.Serial serial = new GT.Interfaces.Serial(socket, 115200,
GT.Interfaces.Serial.SerialParity.None,
GT.Interfaces.Serial.SerialStopBits.One,
8,
GT.Interfaces.Serial.HardwareFlowControl.NotRequired,
null);
serial.Open();
serial.DataReceived += new GT.Interfaces.Serial.DataReceivedEventHandler(serial_DataReceived);
}
void SetupUI()
{
window = display.WPFWindow;
layout = new Canvas();
text = new Text("0");
text.Height = 50;
text.Width = 250;
text.ForeColor = Colors.Black;
text.Font = Resources.GetFont(Resources.FontResources.NinaB);
text.Visibility = Visibility.Visible;
layout.Children.Add(text);
Canvas.SetLeft(text, 40);
Canvas.SetTop(text, 40);
window.Child = layout;
}
void serial_DataReceived(GT.Interfaces.Serial sender, SerialData data)
{
byte[] buffer = new byte[sender.BytesToRead];
sender.Read(buffer, 0, buffer.Length);
string output_t = bytesToString(buffer);
text.TextContent = output_t;
Debug.Print(output_t);
buffer = null;
output_t = null;
}
public static string bytesToString(byte[] bytes)
{
string s = "";
for (int i = 0; i < bytes.Length; ++i)
s += (char)bytes[i];
return s;
}
}
}