Maxime Matter
Maxime Matter

Reputation: 199

Communicate between my UWP app and my rfxtrx433e

I'm writing a UWP (universal Windows Platform) app to communicate with my RFXTRX433e. I'm able to connect to the correct serial device but not able to write anything. Actually the methode for writing looks to work (I don't get any exceprion) but it seems that my USB device doesn't get the info (light is not switched on when sending the packet).

var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(aqsFilter, null);
            using (SerialDevice serialPort = await SerialDevice.FromIdAsync(myDevices.First(o => o.Name == "RFXtrx433").Id))
            {   
                //Get the reset package
                var reset = ProtocolManager.ResetPackage;                   
                using (DataWriter writer = new DataWriter(serialPort.OutputStream))
                {
                      writer.WriteBuffer(buffer.AsBuffer());
                }

Have someone any idea what is going on here?

Upvotes: 0

Views: 292

Answers (2)

Maxime Matter
Maxime Matter

Reputation: 199

Here is the final solution:

   using (DataWriter writer = new DataWriter(serialPort.OutputStream))
    {
         writer.WriteBuffer(reset.GetPacket().AsBuffer());
         await writer.StoreAsync();
         await writer.FlushAsync();
    }

Upvotes: 1

Vincent
Vincent

Reputation: 3746

The DataWriter is using an internal buffer to retain data until your packet is ready.

The data are committed to the stream only when calling the DataWriter.StoreAsync() method. You can also call DataWriter.FlushAsync() to complete the write operation

Upvotes: 0

Related Questions