Jump to content

Recommended Posts

Posted

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?

Posted

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?
Posted

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?

Posted

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

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?

  • 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
×
×
  • Create New...