NetTalk Central

Author Topic: Can Net Talk APP control a local serial port.  (Read 728 times)

rjolda

  • Sr. Member
  • ****
  • Posts: 272
    • View Profile
    • Email
Can Net Talk APP control a local serial port.
« on: October 22, 2023, 02:20:34 AM »
 :NT 14.08
Clarion 11.0.1136
Hi,
I want to be able to send and receive characters from/to a local serial port. I guess it would be like reading a serial barcode reader. 
1. Is it doable?
2. What are the steps and the tricks.
Many thanks,
Ron

Jane

  • Sr. Member
  • ****
  • Posts: 349
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Can Net Talk APP control a local serial port.
« Reply #1 on: October 22, 2023, 01:13:57 PM »
WinEvent has serial port support.

Things to be careful of (top of my head, I've not actually done it):

Decide what thread to use for your WinEvent process.  Definitely not the web server's thread.  Either use the thread of a web request (which will be blocking for that request  if you wait for a reply) or have the web request start a process on another thread.

Use session values for whatever goes in/out of the serial port.

Or if you're just monitoring occasional data, you could have a separate thread window with a timer that queries your com port every XXX and sticks anything it gets into a table (memory or persisted) that you can then view with a regular NetTalk browse.


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: Can Net Talk APP control a local serial port.
« Reply #2 on: October 22, 2023, 11:24:25 PM »
Hi Ron,

So, as you clarified, you want the _browser_ to talk to the Arduino.
The _server_ talking to the Arduino is, of course, trivial.

Up until recently, the answer would have been "no". The browser is "insulated" from local hardware, which in turn means no access to the serial port.

However, in the last couple years there has been movement in this area. There is a Web Serial API developing (https://developer.mozilla.org/en-US/docs/Web/API/SerialPort) however it is not yet a standard. That means support in browsers varies, and indeed it may change before it becomes a standard, so code using it should be considered "might need to replace in the not too distant future."

It will have all the normal restrictions - only over HTTPS, only after user gives permission, and so on - but hopefully will progress from the "experimental" stage to the "standards track" stage at some point.

I'm held back on implementing it as a feature in NetTalk for now, because of the experimental nature of it. However it's a pretty small API so could easily be implemented with some JavaScript.

For personal use, I'd say it's ok to use, but I'd be wary of using it in a commercial setting at this point.

cheers
Bruce

rjolda

  • Sr. Member
  • ****
  • Posts: 272
    • View Profile
    • Email
Re: Can Net Talk APP control a local serial port.
« Reply #3 on: October 23, 2023, 02:20:08 AM »
Jane and Bruce,
Many thanks.  The Browser is supposed to be in its own sandbox so tat rules out serial port.  However, as you pointed out Bruce, there is an API development effort for Serial port.  I will watch that but wait to try to implement that.  Will follow some of Jane's suggestions for now.
Thank you,
Ron