1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Input from Serial Device (Arduino)

Discussion in 'Development' started by Phillip, Feb 28, 2015.

  1. Phillip

    Phillip Member

    I need to input machine operating parameters from an arduino and dump them to our Syteline DB tables. The arduino will be connected to COM1. How should I go about doing this? I was reading that an INPUT STREAM FROM opsys-device command may work but I didn't know how to set it up. The arduino would be outputting 3 values each serial output.


    Note: we are running 9.1E just as an FYI
  3. KrisM

    KrisM Member

    Are you running on a system with .NET Framework ?
    .NET has a class System.IO.Ports.SerialPort that you might access through DLL calls.
  4. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

    I seem to remember we did something similar in one of my previous jobs. We actually used a small VB script to get the info from the serial port as it was easier and more reliable than the Progress solution. I can't remember how we then got that information into Progress, but I'd have thought that's more trivial than getting the data from the serial port in the first place.
  5. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

  6. Cecil

    Cecil 17+ years progress programming and still learning.

    About 10+ years I was using the MSComm32.ocx library to communicate with serial devices. But since it's been such long time ago I'm not sure if the OCX are compatible with the latest Windows Operating systems.

    MSDN Reference:

    Download Microsoft Visual Basic OCX controls:

    Alternatively is possible to modify the Arduino to also include a Ethernet Shield and do the communications via a network connection. Or link the Arduino to a Raspberry Pi which includes a web server???
    Unfortunately I do not have the skills to tell you how to do any of this.
  7. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

    The big issue with anything OCS related is it becomes a nightmare once you start working with 64bit Progress clients and is therefore not future proof.
  8. Cecil

    Cecil 17+ years progress programming and still learning.

    Thinking a bit outside of the box you could use python to read the serial data from the Arduino and then write the contents to a file on disk. Using 9.1E 4GL read the newly created file into temp-tables or whatever you want.

    You should be able to execute the python program via OS-command process.

    I know this seams to be a bit of a stepping stone approach to read the serial data but I think it will be easer to implement. Basically the 4GL/ABL does not have a native serial read/write handling functionality. Also you don't need to get into all that messy .NET stuff.

    Hope that helps.

    I've even found some code to do the job.
  9. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

    I prefer VB but that's just me ;)
  10. Cecil

    Cecil 17+ years progress programming and still learning.

    Not promoting one language over another, I just choosed python because of it's portability across operating systems. I personally I try and develop code which can work on Windows or Linux.
  11. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

    That's a fair point.
  12. Phillip

    Phillip Member

    Thank you for the code! This is the path that I was thinking of taking by just sending a serial command to the Arduino, having it dump the file to the network and then having the program pick it up.

    They have the Arduino Yun now that has linux built into it. Similar to the Raspberry Pi, however, Arduino's have higher power output to the pins so that would be ideal in case I want to run relays in the future. Does this sound like a good way of doing this? Have the linux system dump the text file based on a serial input from the tablets over wifi?
  13. tamhas

    tamhas ProgressTalk.com Sponsor

    Under Unix, I have done this sort of thing in the past by fastening a pipe to the node corresponding to the device and input-output to the pipe from ABL.
  14. joey.jeremiah

    joey.jeremiah ProgressTalk Moderator Staff Member

    I would prefer C/C++ for these sort of tasks and almost any other tasks not found in Progress/OpenEgde.

    You can find an almost endless number of libraries (with tons of samples) especially for these sort of low level tasks that you can find right in the OS (Windows, GNU). I'd challenge people to find lots task that don't have a C/C++ library.

    Lastly, Progress/OpenEdge 4GL/ABL support for calling C/C++ libraries (.DLL/.SO) is extremely simple. Far better than most other languages I've seen.
    Last edited: Mar 6, 2015
  15. Cecil

    Cecil 17+ years progress programming and still learning.

    The ownly problem I have with calling .dll is the inability to handle events.
  16. joey.jeremiah

    joey.jeremiah ProgressTalk Moderator Staff Member

    Yes. You're right handling events would be a problem although you could use sockets for messaging/events but honestly, I've never needed to handle events from a library.

    Again, they will probably have the best performance, they're not just Windows only but probably support the most number platforms and the number of libraries about anything is incredibly big especially about low level OS operations like this.

    To me, a C/C++ library would seem like a more solid rather than an ad-hoc solution in any other language.
  17. Cecil

    Cecil 17+ years progress programming and still learning.

    At the weekend I actually bought an Arduino UNO Starter Kit for the kids (and me). After a few hours I realised that to use this device practically in a real word environment it needs to be networked.

    For the Arduino there are a bunch of shields you can buy, having a Ethernet or WiFi shield IMHO is the best solution to having any type of communication between a server and the Arduino. I did not realise how simple these things are to programme. It's possible to send an HTTP POST request to a WebSpeed Server with whatever clear text data the arduino is generating.

    Some of the Ethernet Shields I have seen also come with a SD card interface so it you can collate the data and the push that data to a Web Server.
  18. Cecil

    Cecil 17+ years progress programming and still learning.

    Well over two years on and I have completely immerse myself in tinkering with Arduino, AVR board and ESP8266 development boards. I love how easy it is to make something that does 'something' over a WiFi network or even the internet.

    I've made a Wifi IR remote which now enables me to control my AC Heat Pump in the mornings so I don't have to get out of bed, all from my iPhone.

    Because ESP8266 uses TCP over the Wifi it's quite simple to integrate with a OpenEdge WebSpeed or REST server.

    My favorite is the Wemos D1 mini because of it's stack-able shields and it's soooo cheap NZ$4.25 / US$3.04. ESP8266 ESP-12 USB WeMos D1 Mini WIFI Development Board
  19. Cringer

    Cringer ProgressTalk.com Moderator Staff Member

    Have you made anything with practical uses in the OpenEdge realm? Would make for a great geekout session at a PUG conference!
  20. TomBascom

    TomBascom Curmudgeon

    For the "do something practical" I suggest "order a beer" :)
  21. Rob Fitzpatrick

    Rob Fitzpatrick ProgressTalk.com Sponsor

Share This Page