Jump to content

Rs232 Data Capture


Recommended Posts

I have taken snippets of code from the forum as well as some from MSDN, but all i'm receiving from this program is zero's. I have com1 connected to a device that supplies raw data (i.e. text) but I never see any of it. The program returns thousands of zeros and just seems to stop. Am I missing something in my code?

$NetComm = ObjCreate("NETCommOCX.NETComm")
$NetComm.CommPort = 1;Set port number
$NetComm.Settings = "9600,N,8,1";Set port settings
$NetComm.InputLen = 0;reads entire buffer
$NetComm.InputMode = 0;reads in text mode
$NetComm.PortOpen = "True";opens specified COM port
While 1
        ConsoleWrite($NetComm.InputData)
WEnd

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

I have taken snippets of code from the forum as well as some from MSDN, but all i'm receiving from this program is zero's. I have com1 connected to a device that supplies raw data (i.e. text) but I never see any of it. The program returns thousands of zeros and just seems to stop. Am I missing something in my code?

$NetComm = ObjCreate("NETCommOCX.NETComm")
$NetComm.CommPort = 1;Set port number
$NetComm.Settings = "9600,N,8,1";Set port settings
$NetComm.InputLen = 0;reads entire buffer
$NetComm.InputMode = 0;reads in text mode
$NetComm.PortOpen = "True";opens specified COM port
While 1
        ConsoleWrite($NetComm.InputData)
WEnd
what kind of device is it attached to? what program is that data supposed to be directed at?
Link to comment
Share on other sites

The device is a register from Verifone. It is set up to have a Virtual Journal Printer. This is the port I am hooked to with COM1 on my pc. The virtual journal port supplies raw data in text form of all transactions on the register. All I am trying to do at this point is retrieve the data from this port and display it using the consolewrite function in autoit. Upon getting that far I intend to write the data to a database.

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

The device is a register from Verifone. It is set up to have a Virtual Journal Printer. This is the port I am hooked to with COM1 on my pc. The virtual journal port supplies raw data in text form of all transactions on the register. All I am trying to do at this point is retrieve the data from this port and display it using the consolewrite function in autoit. Upon getting that far I intend to write the data to a database.

ok, a couple of things to check, do you have any lights or indicators on the register to say that it's not hooked to a printer, or a communication error? also, does the register show as connected in your device manager? the reason i ask, is that either device may not be acknowledging the connection, in which case not trying to actually communicate.
Link to comment
Share on other sites

No lights to check. I can however open hyperterminal on com1 and see the data stream by.

Edited by sykes

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

Take a look at some of the posts at

http://www.autoitscript.com/forum/index.php?showtopic=13890

Some of the syntax might have changed, but I *think* the current beta of AutoIt should be compatible with the posted code samples.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Take a look at some of the posts at

http://www.autoitscript.com/forum/index.php?showtopic=13890

Some of the syntax might have changed, but I *think* the current beta of AutoIt should be compatible with the posted code samples.

Thats where I got the code I've been using ... Just can't seem to receive the data :)

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

I used NETComm.ocx because it is free and redistributable. All Properties, Methods, Events, etc, etc are the same as MSCOMM32.OCX with the exception of the Input property (it's InputData in NETComm.ocx).

I played with the code this morning and was finally able to get it working.

Working code is below:

HotKeySet("{ESC}", "_KillDaWabbit")

$NetComm = ObjCreate("NETCommOCX.NETComm");Create NETComm.ocx object

;Set object settings
With $NetComm
        .CommPort = 1               ;Set port number
        .Settings = "9600,N,8,1"    ;Set port settings
        .InputLen = 0               ;reads entire buffer
        .InputMode = 0              ;reads in text mode
        .HandShaking = 3            ;uses both RTS and Xon/Xoff handshaking
        .PortOpen = "True"          ;opens specified COM port
EndWith

While 1
    _GetData()
WEnd

Func _GetData()
    If $NetComm.InBufferCount > 0 Then      
        ConsoleWrite($NetComm.InputData)    
        Sleep(250)                          
    EndIf
EndFunc

Func _KillDaWabbit()
    Exit
EndFunc

Adding the HandShaking property was what finnaly enabled me to retrieve the data.

Edited by sykes

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

Use portmon from sysinternals to see if there are any activity at all on the port.

Happy for you that you got it working :)

Link to comment
Share on other sites

  • 4 years later...

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