NetTalk Central

Author Topic: Webserver and WinEvent serial port  (Read 3093 times)

KC Chin

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • Email
Webserver and WinEvent serial port
« on: November 14, 2018, 01:28:52 AM »
Hi,
I know how to read the serial port without problem.

Question is how to I post it the web from webserver? I just need to update a single field in real time (maybe a delay of 2 seconds or so) where the webserver is posting the value to client side.

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: Webserver and WinEvent serial port
« Reply #1 on: November 14, 2018, 02:36:43 AM »
Call a very simple window procedure from a NetTalk procedure.  Execute your WinEvent code in the window passing the value(s) as a parameter back to your NetTalk procedure.  Put value(s) in session value(s) or wahtever you need. 

I think that may work.
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

KC Chin

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • Email
Re: Webserver and WinEvent serial port
« Reply #2 on: November 14, 2018, 04:32:53 PM »
Hi Don,

Yes, call a proc from NT webserver.... How and Where to code it? :(

Anyway, I am checking out the example "Timers (46)" and "WebSockets (82)". Trying to understand and figuring out how it works.

The "WebSockets (82)", Net:h:UsersOnline, how this variable increment or decrement the value.  Also, cannot find this Global host variable "UsersOnline" data type.

KC Chin

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • Email
Re: Webserver and WinEvent serial port
« Reply #3 on: November 14, 2018, 04:59:30 PM »
http://www.nettalkcentral.com/forum/index.php?topic=7327.msg29753#msg29753

The example "Calculator (34)"
This is then one example "http://127.0.0.1:88/Performance" will help me to display Serial Port data.
Now this is getting interesting...
I don't think I may getting into trouble if I place a variable, Loc:ReceivedValue from serial port.

More likely it will work and stream the Serial Port data out in real time.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11175
    • View Profile
Re: Webserver and WinEvent serial port
« Reply #4 on: November 14, 2018, 10:10:17 PM »
Hi KC,

not 100% sure what you are wanting here, but

a) I think you want a NetWebForm with a Display field on it, set as "live via web socket" and pointing at a host variable (call it anything you like - say 'kelvin')

b) In the WebServer procedure, on the timer event, you can read the comms port and put the result into the host variable with the same name. like
s_web.SetHostValue('kelvin',whatever)

If this is all set up then the new value will appear in the browser window whenever it arrives at the server.

(hint: it will come in 1 char at a time, so you probably need to wait for a CR/LF or some other "end of packet" character before pushing it into the host value.)

cheers
Bruce

KC Chin

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • Email
Re: Webserver and WinEvent serial port
« Reply #5 on: November 15, 2018, 12:52:03 AM »
Bruce,

The example "Calculator (34)-Performance"  section already give me the head start using the websockets.
I don't think it will be difficult to do.