Bit OT - databases and writing software for serial I/O - Page 1
Forum section: electronics / general

author: mc
author_rank: Regular Contributor
timestamp: March 30, 2013, 02:48:36 pm
content: This is a bit off topic, but I'm hoping some people here have some recommendations, or at least act as a sounding board for my thoughts.For a bit of background, as part of some voluntary club work I do we run several races throughout the year, which led me to write some scripts in PHP that run on a local webserver, that allow me to input times manually, link them to create a list of results, then display them. The webserver allows some flexibility to link computers and have various displays. All this is done on computers running windows (easily accesible, and I can use any that can connect to a network)However, I've now developed hardware that will automatically output the times via UART/Serial and into a computer. Now after some searching, PHP on windows only allows you to output/write to Serial using the php-serial class, so I'm looking at alternatives. Ideally I'd like to continue using MySQL, but am not 100% set on that decision.I had thought writing a windows application that could simply read the serial port, then insert the data straight into the MySQL database, however VisualStudio Express only has MS database facilities (and this project doesn't justify the $$$$ cost of VS Pro to be able to access mysql!).I could alter the PHP to use a MS database instead, however I was hoping to keep this project cross platform capable and avoid too much operating system lockin.So what other Programming language packages are there I should consider?Or where/what should I be looking for to find suitable packages/information?I'll admit that the last non-web server or hardware programming I done was well over 10 years ago, so I'm open to all suggestions, as I'll be pretty much starting from beginner level :-/

author: ecat
author_rank: Frequent Contributor
timestamp: March 30, 2013, 03:16:05 pm
content: I know nothing of VisualStudio Express, however this posthttp://social.msdn.microsoft.com/forums/en-US/Vsexpressvb/thread/3419849a-87bc-4d5a-9fd8-33c9410f4e26suggests you may be able to use ODBC which is fastest acting known cure for most database connectivity ailments. The MS ODBC namespace looks to be typical MS gobbledegookhttp://msdn.microsoft.com/en-us/library/system.data.odbc.aspxbut I'm sure you can find some examples to get you started.If all else fails can you just write the values from the serial port to a text file and have the php read the file and store to MySQL?

author: PA0PBZ
author_rank: Super Contributor
timestamp: March 30, 2013, 03:51:40 pm
content: Have a look at MySQL Connector/Net :http://dev.mysql.com/downloads/connector/net/

author: mariush
author_rank: Super Contributor
timestamp: March 30, 2013, 03:53:12 pm
content: I'm not sure you can't read and/or write with php in Windows.You should be able to, it's just a bit convoluted.MODE command sets various serial port modes , just open a command prompt and run mode /?Here's a php class that seems to support Windows :https://github.com/rubberneck/php-serial/blob/master/php_serial.class.phpOtherwise you might want to have a look at Free Pascal and the Lazarus IDE for it - if I remember correctly I think it had sample applications for reading/writing to serial port , using mysql with it, and I think also making a basic web server.So you could make a tiny free pascal app. that would read/write serial port and buffer the data and then either write directly to mysql or from php you could connect to the free pascal app and retrieve the buffered data through a http connection or a windows pipe

author: mc
author_rank: Regular Contributor
timestamp: March 30, 2013, 04:13:42 pm
content: VS Express only supports MS "datasources" via ODBC. If you want non-MS DB support, you've got to pay for VB.Quote from: mariush on March 30, 2013, 03:53:12 pmThat's the issue. I'm sure with much tweaking it can be done, but I'm wanting something that's as easy to setup as possible.I probably should of said I'm not set on using PHP/mysql, I'd just rather avoid having to deal with limitations of free versions of paid software. Ideally I'm looking at something capable of having a central database, which can be accessed via any computer without installing anything, however I'm willing to have to install software on the main computer for the purpose of handling the input.I've just been doing some searching, and either Java or C/C++ via Netbeans looks promising.

author: ve7xen
author_rank: Super Contributor
timestamp: April 01, 2013, 08:07:56 pm
content: Pretty much any scripting language could fill the place of PHP (in much nicer fashion, too) here. I'd recommend Python, but you could also easily use Perl or Ruby or .... You probably will have to install the platform-specific serial port modules and SQL interface driver modules. I have used PySerial in the past with good success. You can use Py2exe to bundle all of the required modules and script into a single .exe file you can run on any machine without installing anything once you've got the setup working.

author: MacAttak
author_rank: Unknown
timestamp: April 02, 2013, 02:33:49 am
content: Yeah, I would go with Python. There are lots of options with it. It supports sql lite natively, and you can find code to use it with mysql and also serial ports. Python itself is an extremely concise and user-friendly language to work with. It was originally created as an aid for teaching programming concepts, so it was kept fairly simple.I'm a bit biased since I am a contributor to the IronPython core projects, but if you are going to be running this on Windows then I highly recommend checking out Python Tools for Visual Studio (http://pytools.codeplex.com/). This is a first-class development environment - really amazing features actually. You probably wouldn't care about all of the MPI and Cluster support, but the Debug REPL and Intellisense/debugging features are worth it by itself. The IronPython runtime is pretty good too - one of the fastest implementations (close to CPython for many things).Python Tools is free and open-source (just like IronPython itself). You don't even need to pay for Visual Studio - it can use the free "empty shell" version, which is just the IDE framework. If you already have Visual Studio installed though, it will just extend it with the Python support.Learning Python will also be useful if you ever pick up a Raspberry Pi.

author: amyk
author_rank: Super Contributor
timestamp: April 02, 2013, 10:21:11 am
content: Quote from: mc on March 30, 2013, 04:13:42 pmODBC is a (cross-platform) standard. There's no reason why it won't work with any other database as long as there's an ODBC driver available.

author: mc
author_rank: Regular Contributor
timestamp: April 02, 2013, 05:01:26 pm
content: Cheers for the suggestions.I've also now downloaded python to have a play with, however I'm away for work for a few days so won't be able to try it til I get home.

author: Galaxyrise
author_rank: Frequent Contributor
timestamp: April 02, 2013, 08:39:55 pm
content: Quote from: mc on March 30, 2013, 04:13:42 pmI don't see how that's possible... ODBC is part of the PlatformSDK, not a part of Visual Studio. Just include sql.h and link odbc32.lib. Maybe you're confusing with the IDE's ability to connect to a database and perform queries against it? (But you don't need that feature; you've got MySQL tools.)ODBC is a real pain, though. I highly recommend going through some wrapper layer rather than coding to ODBC directly.