Sign in to follow this  
Followers 0
sykes

Rs232 Data Capture

12 posts in this topic

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?

Share this post


Link to post
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?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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?

Share this post


Link to post
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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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?

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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

Oh, sorry then. I saw your ObjCreate("NETCommOCX.NETComm") line and thought you were using something different.

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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?

Share this post


Link to post
Share on other sites

#10 ·  Posted

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

Happy for you that you got it working :)

Share this post


Link to post
Share on other sites

Maybe anybody solve this situation with portmon.exe?

(ports not viewed)

see sysinternals forum:

http://forum.sysinternals.com/topic15200.html

Share this post


Link to post
Share on other sites

solution is disabling non hw ports!

See my answer on sysinternals forum!

example:

Posted Image

Share this post


Link to post
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
Sign in to follow this  
Followers 0