Jump to content

Reading data from a serial port to a varible


Recommended Posts

First of all I would like to specify exactly what Im trying to accomplish.

All data from com1 -> File/Varible *prefer varible

Data from varible -> Format it (done)

Formatted Data -> Mysql Database (done)

Mysql Info -> PHP website (done)

I'm not sure if this exists in autoitx dll or if I can somehow load another dll into autoit or if someone has built a function/addin to do this. My goal here is to read the serial port (com1) (infinite loop) into a varible, the current method Im using for this is a run command that say COPY COM1 SOMETEXTFILE.TXT however this has proven not to be a option.

Ive searched the helpfile, the faq, the forums and google to my wits end and this is the first time those haven't answerd my questions when it comes to autoit someone please help :)

Edited by chrish
Link to comment
Share on other sites

Maybe this should be included in the autoit notes under the fileopen section, and a refrence made in the help file that points a user searching for com port or serial or com with the fileopen command, Just a suggestion :).

My working example now I can't belive it was so freaking easy god I love autoit.

$comport=FILEOPEN("COM1", 0)
$tmp="C:\PHONE\TEST.TMP"

While 1
   $data = FILEREAD($comport, 1)
   $output=FILEOPEN($tmp,1)
   FILEWRITE($output,$data)
   FILECLOSE($output)
Wend

Im using it as a open file handle I didn't even think you could do that untill I searched for the dll and started asking myself how is this different then opening a file handle. You see of course the above code just writes it to a file but I could change this very quickly and just use the varible, TY for your help JPM even though Im not calling a dll you still made my brain click.

Edited by chrish
Link to comment
Share on other sites

Cool. This should definitely be mentioned in the help file. Sending to com port (FileWrite) doesn't seem to be possible, right?

<{POST_SNAPBACK}>

Not sure I cannot try it with the device I have although someone is more then welcome to test this out with something like a serial modem.
Link to comment
Share on other sites

Wow, this is very cool and could be extremelly helful! How did you know about it? how comes that this is not on the help file? It is a pretty major feature, in my opinion!

And why can't you use this to write to the port? If it was possible you could very easily create an AT command interpreter with autoit, which would be fantastic.

I have a question though, what happens when you try to read and there is nothing to read? Does the function simply block the program execution? I hope it doesn't.

I am sorry, I can't test is from home :-(

Cheers,

Angel

Link to comment
Share on other sites

  • 1 year later...

I am looking to read data from the com port to for my GPS and it just returns "", no error.

I googled around I still no help

can someone help, THank you

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...