dotnet / iot

This repo includes .NET Core implementations for various IoT boards, chips, displays and PCBs.
MIT License
2.16k stars 582 forks source link

Virtual devices & signalr #78

Closed grahamehorner closed 3 years ago

grahamehorner commented 5 years ago

Please consider creating a set of virtual devices that simulate the physically state/operations of the hardware, and can be used without the need of the developer to have access to actual hardware.

E.g.. the device driver for a virtual SPI interface could make use of Signalr to send (almost realtime) state updates and/or operations to a web, windows, mobile ux. using a similar concept to device twins.

IMHO this would help developers and improve testibility and reduce the developer inner loop when creating driver/controllers.

joperezr commented 5 years ago

I agree that having this would be great. TBH I'm not super familiar with SignalR so I don't know how costing would look like to have this, but it would definitely help inner-loop and validation since you would be able to have tests without relying on the hardware.

grahamehorner commented 5 years ago

@joperezr I'd be happy to do a proof of concept for a virtual GPIO based around signalr/websockets; to see if this is possible and/or is a good fit for the developer inner loop/testing without the need for hardware.

joperezr commented 5 years ago

That would be great! 😄

grahamehorner commented 5 years ago

@joperezr I've start looking into this and I'm building up a set of IObservable and IObserver classes that will represent the physical components within a circuit and the voltage/current etc.

FYI, I'm looking to have a basic ADC virtual circuit working by mid/end of next week; I'm dug out an olde copy of a book I had used many year ago Electronic Circuit & System Simulation Methods (SRE) by Lawrence Pillage

shaggygi commented 5 years ago

@krwq @joperezr I've started playing with this repo (Project TIOT). It's basically a dumping ground for me trying to learn about related topics. However, it might help with this issue. It is still "very" early, but looks promising. I was already able to perform many of the GPIO-related features and was successful communicating with I2C (but is far as I got for now). There is a basic example using with a WPF app, as well.

If it gains traction/support, it might be a good idea to move over to the tools section.

Again, this is nothing more than a playground for myself learning topics and repo could be removed at some point. Just thought you might be interested.

Much more to do as time allows. 🎉

krwq commented 5 years ago

@shaggygi perhaps you could use Firmata to do stuff remotely: https://github.com/dotnet/iot/issues/262 - I bet same stuff will work for Pi and Arduino.

For many scenarios TCP connection will do but in some cases you might have to send a program which executes remotely (I don't know if firmata has capabilities like that but might be worth taking a look since it seems it has similar goals in mind)

shaggygi commented 5 years ago

@krwq Thanks for the link. I had not come across that one yet. It seems this is the same concept I'm trying to do with TIOT, except Firmata appears to use serial/USB (which is still a good idea) instead of gRPC & Ethernet. I'll try to read over the content/topic. Thx

krwq commented 5 years ago

@shaggygi if we decide to implement it, might be worth to just depend on Stream and then you can either pass a serial stream or tcp/other stream depending on what you need (perhaps we can have an overload which uses serial by default as well but stream should be main API).

I haven't looked into Firmata yet though to give you any opinions on the subject (it was somewhere on my todo list but probably won't have time for that for a while)

krwq commented 3 years ago

[Triage] How should do APIs look like for this?

Ellerbach commented 3 years ago

[Triage] We now have multiple way of doing this: -Arduino with Firmata support

Question is: is this issue still valid?