![]() |
Serial Communication: BASIC to Python
This thread is essentially a continuation of this one; however, my problem now is translating BASIC code to Python.
I got ahold of a small piece of BASIC code someone was using to communicate with the device I described which connected to the serial port: :
INPUT ; "Enter filename to save data- ", outfile$ |
Have you tried that BASIC program on your XP machine?? http://www.daweidesigns.com/images/eyebrow.gif
|
Windows XP will not be happy about that program, it will most likeley crash.
|
Quote:
Python came along much later, when it became fashionable to have libraries and modules, rather than inbuilt functionality, and when serial ports had become more or less obsolete. Just because functionality is inbuilt into a language, doesn't mean it doesn't have overhead. At least when something is an external module you have a choice whether to use it or not. |
What platform does that code run under? This is closets I could find to explaining that function call, it is for m the help manual for liberty basic. Which is windows only. Both python modules are portable on windows,linux and mac.
Using USPP I think the code translates (roughly) to: :
from uspp import *Because I can't get the refernce material online, I am not sure I am using the read method properly. |
The reason I asked if that BASIC runs is that the code appears to date back to real-mode days, when one could access ports directly. That is no longer the case. For that to run, the interpreter would have to drop out of protected mode, just as driver or kernel code has to.
|
This is all very interesting. It sounds like PySerial/USPP is the way to go.
And Dawei, I don't know if it runs because I haven't had a chance to connect the device to my computer yet (It's very large). |
You would have to have a BASIC interpreter (with or without a BASCOM) to use it, anyway. That code indicates that the equipment is rather straightforward, anyway. I have a link here somewhere to serial access via C/C++, but I'm not finding it. I'd probably use Python, though, if it were me.
|
| All times are GMT -5. The time now is 12:50 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC