receiving Wifi Shield data from Cyton, in C#

RadaMikeRadaMike Dallas
edited July 2019 in Wifi Shield
I am rather new when it comes to moving from one software to another, but even so i need to receive data from the wifi shield attached to the cyton in C#.
I seem to be having difficulty with the initial stages of actually receiving the C# data without using the OpenBCI GUI. I am unfamiliar with how the wifi shields data is received by the openBCI GUI.

My question is how do i receive the data that the GUI is receiving in C# or how can i begin to go about that? 
I cannot use the GUI down the line and am trying to incorporate the data into a C# application I've been working on for some time.

Comments

  • wjcroftwjcroft Mount Shasta, CA
    Mike, hi.

    There are some other threads on C#,


    For example, this example of receiving from Cyton via the dongle serial port,


    That might at least get you started.

    As far as an alternative way to receive the Shield data, it can be done by running the OpenBCI_GUI, and using the Networking Widget to output a data stream in LSL, LabStreamingLayer format. There are then C# library routines to read LSL,


    Regards,

    William

  • Thanks William,
    I am reading through the C# now. thanks for sending that my way.

    I have two followup questions.
    Can i get a faster than 250Hz sample rate using the dongle serial port if i only want 2 channels? I would assume yes if i replace channel 3-8 with just channels 1 and 2 sampled faster at ~1KHz

  • wjcroftwjcroft Mount Shasta, CA
    Mike, hi.

    re: dongle 2 channels at 1 kHz. 

    This is theoretically possible, but would be a lot of difficult firmware work. For one thing, the RFduino's (dongle and mainboard), send one sample over the air in a packet, 250 times/sec. That packet contains 8 channels of data, plus aux channels for accelerometer, etc. Also control data. 

    re: receiving shield data at 1kHz.

    Have you already tried this with the GUI? Is that working for you? Is UDPx3 working, that appears the best protocol.

    If you can get the GUI receiving reliably from the shield at 1 kHz, then you can use the Hub interface spec to have your C# connect and receive that stream, without actually needing to run the OpenBCI_GUI Processing app. However the Hub app is still involved.


    Regards,

  • Thanks for the timely reply William, (I appreciate all your effort in communication)

    so for the dongle 2 channel at 1KHz i think i will give it a go and let you know if i have any success. I intend to replace the 3-8 channel before they are sent in the package as well as use the remaining 33-24 -1 -1 = 7? bytes to have a digital read line and possible three time stamps that tells the difference in between the 2nd,3rd,4th sample and the original time of the 1st sample which should fit into my remaining 6 bytes i hope.

    For the wifi shield i have been successful in recieving 1kHz using only UDP not UDPx3. im not sure i understand the difference there. I enjoy the faster sampling rate and have seen that i can achieve a faster sample rate from the wifi shield as well. how do i achieve a 2kHz sample rate using the openBCI software?

    I will test having the wifi shield stream the data through the hub to C# but likely if i have to run the processing app that wont work in the long run. thanks for the info.

    I have "rewritten" the C# code so that i am more comfortable with it and am able to recieve from the dongle at 250Hz. Thank you very much for sending that C# code my way. :)


  • wjcroftwjcroft Mount Shasta, CA
    re: "but likely if i have to run the processing app that wont work in the long run"

    The Hub operates by itself and does not need the GUI. For an example of a C based app that reads Ganglion data from the Hub, see BrainBay source code.

    re: UDP

    UDPx3 sends each packet 3 times. UDP has no error correction, unlike TCP. Unfortunately the ESP chip on the shield has sometimes buffering issues with TCP that cause lossage. UDPx3 is a good compromise. UDPx3 works fine with Ganglion. Apparently it is not working for you? Another user Kris, has also remarked that UDPx3 is not working with his Cyton.

    What is your application that requires 1 kHz sample rate?

  • I will look into BrainBay. does that mean that C# reads from the Hub but the Hub isnt a program its data in a local port? like when i run my C# program i want that to be the only program open.

    I havent used the wifi board in a few days so just to try again i checked if UDPx3 works and it does not. UDP works after i press the start button twice. Once closes the menus but does nothing that i can tell. The second press starts streaming my data.

    The reason i want 1Khz is because i plan on stimulating different areas with stimulation lengths that are sub 1ms in duration. I need the 1Khz or 2Khz sample rate because i can miss part of the response otherwise.

    Thanks,
  • wjcroftwjcroft Mount Shasta, CA
    The Hub is an app, separate from the GUI (Processing based) app. So I think you are saying you are aiming for minimum latencies and maximum real time responsiveness. 

    Your C# CAN directly interact with the Shield (and thus Cyton), but it may be less documented. In this case no Hub app is involved. I only suggested the Hub route because it has more functionality than a direct interface to the shield.

  • Thank you for all the information. ill be working on this for the next few days/ weeks and ill let you know how it goes. 

    Maybe we can create some more documentation after this is all said and done.

    Thanks for the help William
  • wjcroftwjcroft Mount Shasta, CA
    Mike,

    re: the failure of your UDPx3 test. Were you using Wifi Direct, or Wifi Station? Fastest throughput would be with Direct as it bypasses the router.

    William
  • William,

    I was using wifi Direct.

    Michael
Sign In or Register to comment.