1

Alright, I'm tired of googling. So I am working on a project which utilizes Windows Remote Arduino. I'm just starting so I am in the "just hack it together stage." The arduino is running standard firmata and I'm calling a sysex function which returns some data from some sensors.

I've subscribed to the StringMessageReceived Event, but what I'm finding is that event is not always firing. I 'should' be receiving data each time I send the sysex command. I did find a closed issue on the git hub site for remote-wiring that says to call the flush() on the firmata object, which I'm doing, but I'm not getting a 1 for 1 response.

Here's a sample output I'm getting.

Device Ready Event Fired

Timer Tick!

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}

Timer Tick!

Timer Tick!

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}

Timer Tick!

Timer Tick!

Timer Tick!

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}

Timer Tick!

Timer Tick!

Timer Tick!

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}

{\"temp1\":21.50,\"pH\":0.000}

Timer Tick!

Timer Tick!

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}

Timer Tick!

Timer Tick!

Timer Tick!

{\"temp1\":21.50,\"pH\":0.000}"

I know the arduino is getting my commands, because I can see the LED's on one of my sensors processing the command.

Here's my UWP code.

public sealed partial class MainPage : Page
{
    IStream connection;
    RemoteDevice arduino;
    UwpFirmata firmata;
    DispatcherTimer timer;

    public MainPage()
    {
        this.InitializeComponent();
    }

    private void btnConnect_Click(object sender, RoutedEventArgs e)
    {
        connection = new UsbSerial("VID_0403", "PID_6001");
        firmata = new UwpFirmata();
        arduino = new RemoteDevice(firmata);
        timer = new DispatcherTimer();
        firmata.begin(connection);

        connection.begin(57600, SerialConfig.SERIAL_8N1);
        arduino.DeviceReady += Setup;
        arduino.DeviceConnectionFailed += ConnectFailed;
        arduino.StringMessageReceived += StringRecieved;

        timer.Interval = new TimeSpan(0, 0, 5);
        timer.Tick += timerTick;
        timer.Start();
    }

    private void timerTick(object sender, object e)
    {
        Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, ()
        =>
        {
            lblPhData.Text += "Timer Tick!\n";
        }
        );
        byte PH_QUERY = 0x44;
        firmata.sendSysex(PH_QUERY, new byte[] { }.AsBuffer());
        firmata.flush();
    }

    private void StringRecieved(string message)
    {
        Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, ()
        =>
        {
            lblPhData.Text += message + "\n";
        }
        );
    }

    public void ConnectFailed(String message)
    {
        Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, ()
             =>
         {
             lblPhData.Text += message;
         }
        );
    }
    public void Setup()
    {
        Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, ()
             =>
         {
             lblPhData.Text += "Device Ready Event Fired\n";
         }
        );            
    }

    private void btnGetData_Click(object sender, RoutedEventArgs e)
    {
        byte PH_QUERY = 0x44;
        firmata.sendSysex(PH_QUERY, new byte[] { }.AsBuffer());
        firmata.flush();
    }
}

I've got to be missing something really really simple.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
bjbowen4
  • 11
  • 1
  • Hi bjbowen4, after doing more test, I also get the same issue with yours, it happens on both Windows IoT Core(Raspberry Pi 3) and desktop. And I check from arduino side, all commands it can receive but Windows side seem lost some of them. You can open an issue on [remote arduino github repo](https://github.com/ms-iot/remote-wiring/issues). – Rita Han Sep 05 '18 at 03:57
  • Whew, well at least I'm not crazy! – bjbowen4 Sep 05 '18 at 23:24

0 Answers0