clinkme Posted April 24, 2006 Share Posted April 24, 2006 Hello, I'm trying to get binary data from COM port using Microsoft Comm Control.Unfortunatelly, I can read only text string. When I set the MSComm property as $comInputModeBinary, I get nothing in Autoit variable ($A), when data length ($n) is returned OK.Here is my code:#include <GUIConstants.au3>Global Const $comEvSend = 1 Global const $comEvReceive = 2Global const $comEvCTS = 3Global const $comEvDSR = 4Global const $comEvCD = 5Global const $comEvRing = 6Global const $comEvEOF = 7Global const $comInputModeText = 0Global const $comInputModeBinary = 1; == GUI generated with Koda ==);### Koda GUI section start ###$Form1 = GUICreate("Form", 418, 320, 192, 125)$Edit1 = GUICtrlCreateEdit("", 16, 56, 369, 193)GUICtrlSetData($Edit1, "")$Button1 = GUICtrlCreateButton("Open", 16, 264, 75, 25, 0)$Button2 = GUICtrlCreateButton("Close", 104, 264, 75, 25, 0)$Button3 = GUICtrlCreateButton("Get", 192, 264, 75, 25, 0)GUISetState(@SW_SHOW)### Koda GUI section end ###Dim $old$Com = ObjCreate("MSCOMMLib.MSComm.1")$SinkCom=ObjEvent($Com,"MSComm_")$Com.CommPort = 1$Com.InputLen = 0$Com.InputMode = $comInputModeBinary$Com.RThreshold = 1$Com.Settings = "9600" & ",n,8,1" $Com.PortOpen = True$Com.Output = "ATI9" & @CRWhile 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $button1 $Com.PortOpen = True Case $nMsg = $button2 $Com.PortOpen = False Case $nMsg = $button3 $Com.Output = "ATI9" & @CRLF EndSelectWEndFunc MSComm_OnComm() Switch $Com.CommEvent Case $comEvReceive $n = $Com.InBufferCount $A = $Com.Input $old = GUICtrlRead($Edit1) GUICtrlSetData ( $Edit1, $old & @CRLF & $n & ": " & $A) EndSwitchEndFuncThanks in advance, Il Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now