View Single Post
Old Jul 20th, 2006, 4:44 PM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 934
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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$
OPEN outfile$ FOR OUTPUT AS #1

OPEN "COM1:9600,O,7,1" FOR RANDOM AS #2
PRINT #2, "01,TEMP?"
INPUT #2, A$, B$
INPUT #2, C$, D$, E$, F$

PRINT #1, TIME$, C$, D$, E$, F$
If it's possible to do this in just a few lines of BASIC code, it doesn't make sense to me that it should require an entire module (eg, PySerial) to do the same thing in Python. Is there a simpler way to translate this? Thanks for any input.
titaniumdecoy is online now   Reply With Quote