• 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)

#1
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.

Thanks!

Note: we are running 9.1E just as an FYI
 
#2
Are you running on a system with .NET Framework ?
.NET has a class System.IO.Ports.SerialPort that you might access through DLL calls.
 

Cringer

ProgressTalk.com Moderator
Staff member
#3
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.
 

Cecil

17+ years progress programming and still learning.
#5
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:
https://msdn.microsoft.com/en-us/library/aa903551(v=vs.71).aspx

Download Microsoft Visual Basic OCX controls:
http://www.microsoft.com/en-nz/download/details.aspx?id=10019

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.
 

Cringer

ProgressTalk.com Moderator
Staff member
#6
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.
 

Cecil

17+ years progress programming and still learning.
#7
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.
http://stackoverflow.com/questions/20892133/storing-string-from-arduino-to-text-file-using-python
 

Cecil

17+ years progress programming and still learning.
#9
I prefer VB but that's just me ;)
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
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.
http://stackoverflow.com/questions/20892133/storing-string-from-arduino-to-text-file-using-python

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?
 

tamhas

ProgressTalk.com Sponsor
#12
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.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
#13
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:

Cecil

17+ years progress programming and still learning.
#14
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.
The ownly problem I have with calling .dll is the inability to handle events.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
#15
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.
 

Cecil

17+ years progress programming and still learning.
#16
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.
 

Cecil

17+ years progress programming and still learning.
#17
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
 

Cringer

ProgressTalk.com Moderator
Staff member
#18
Have you made anything with practical uses in the OpenEdge realm? Would make for a great geekout session at a PUG conference!