Giter VIP home page Giter VIP logo

Comments (8)

leaanthony avatar leaanthony commented on July 19, 2024

Hi. Arduino is normally embedded. Is there a specific use case you feel should be supported?

from wails.

freedaun avatar freedaun commented on July 19, 2024

Hi Lea, thanks for considering this.

In general browser technologies do not allow access to the local machine, which in practice mostly means that files and ports are not accessible. Besides files, which are essential to almost all applications, access to serial ports in particular is essential to almost all "maker projects".

As most people are familiar with the Arduino, I used that term. I have programmed many Delphi desktop applications, none have ever used any ports other than the serial.

I think it is sufficient to provide access to the data-stream, and to I/Os like DTR. No other functionality would be required (I know some libs allow for parsing the data-stream).

Hope this answers your question. But maybe it didn't. In short I think the maker space is the use case that should be supported. A solution in this space is johny-five+firmata, but it imposes an odd protocol over the serial connection (frontend example: http://johnny-five.io/examples/motor/).


Note that my suggestion gravitates development towards the frontend, because with access to files and serial ports, Go development becomes unnecessary. But I could imagine a system where the emphasis would be on the backend. The frontend would consist of (rather simple) dialogs and visualizations (in a simple vertical stack of elements, all horizontally centered). The backend would process most clicks, update the model in response, and provoke screen updates. The frontend would consist mainly of render functions. This might be even simpler to use, as Go has primitives to easily handle several devices concurrently.

from wails.

leaanthony avatar leaanthony commented on July 19, 2024

If you can create a list of specific things you feel would help this aim, I'm sure we can look into it!

from wails.

freedaun avatar freedaun commented on July 19, 2024

The best project with similar code I've seen is:
https://github.com/johnlauer/serial-port-json-server

In this project all serial port events are packed into JSON, in Wails they need to become a Wails event. The "serial*.go" files in particular are relevant, clarifying all events.

In a Vue example one would be able to:

  • list all ports
  • select a port,
  • assign a baudrate/bitrate,
  • connect to the port,
  • send data and
  • have any data received displayed (including binary)
  • sending/receiving could be interrupted by disconnected/connected events, as the port may have been (temporarily) removed, or the remote device may have been (temporarily) removed
  • serial ports have pins that can control the flow of data, these may need setting and/or reading (the indicated project above lists them in detail). These days hardware control flow is rarely used, and the pins are used as I/O's instead, so it suffices to expose them.

The data is binary (raw bytes), no encoding. Whenever any of the inputs changes (may need polling), an event must be triggered, notifying the new state (of all pins). No need for individual pin updates (because that's easy to do on the frontend itself).

So I see this API:

  • list() => list of ports, and their properties (see project above)
  • connect(port: string, baudrate: int [, parity: enum, stopbits: enum]) => channel | error
  • channel.connected(), notifies of an established connection
  • channel.disconnect() => ok | error
  • channel.disconnected(), notifies of a broken connection, data in serial output buffers has been cleared
  • channel.incoming(string), passing a string of bytes
  • channel.outgoing(string), passing a string of bytes
  • channel.inputs_changed(inputs: u8)
  • channel.outputs_changed(outputs: u8)

A channel.disconnected() can come at any time. If auto-reconnect is supported, disconnected() and connected() events can alternate. Auto-reconnects are desirable as the connection can be suspended by the device, or by the user unplugging a serial port. These events may pass the motive of the break: port unplugged or device disconnected.

Additionally a log data to file feature would be useful (also for debugging), but that's probably better solved by access to the local file-system.

from wails.

leaanthony avatar leaanthony commented on July 19, 2024

I believe everything you need is supported right now - simply write the Go and use it :-) Arduino would be running Linux right?

from wails.

freedaun avatar freedaun commented on July 19, 2024

Arduino would be running Linux right?

No. Arduino is a placeholder for any device attached to a serial port, typically an Arduino, and Arduinos do not run Linux. Could even be a keyboard, or a MIDI device, anything that complies with the hardware of a serial port interface.

But given you're in the dark about serial ports, I guess you're not the right person to do this. Given time I could do this, I would have to figure out how to create Wails events in Go, for the frontend to consume. Doesn't seem difficult, would be my first Go ever though :)

Thanks.

from wails.

leaanthony avatar leaanthony commented on July 19, 2024

Hi. Eventing is pretty easy. I recommend you have a look at the Todo tutorial. That's similar to what you want to do: most of the logic is in Go and when system events happen, they trigger application events. Once you get a runtime object, you can emit and listen to any events.

from wails.

leaanthony avatar leaanthony commented on July 19, 2024

@freedaun Is there anything we need to do to close this now? Thanks.

from wails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.