RS232?
#1
Posted 22 July 2005 - 08:05 PM
-Livewire
#2
Posted 22 July 2005 - 08:47 PM
Edit: Not telnet, just a connection via COM1 or 2...
Edited by MSLx Fanboy, 22 July 2005 - 08:47 PM.
_DateAdd("d", -2, _NowCalcDate())
#3
Posted 22 July 2005 - 10:21 PM
-Livewire
#4
Posted 25 July 2005 - 01:01 PM
#5
Posted 25 July 2005 - 02:28 PM
Here is an example of sending out the letter 'a' over COM port 2 every 2 seconds:
$MsComm = ObjCreate("MSCOMMLib.MsComm.1") $MsComm.CommPort = 2 $MsComm.Settings = "9600,N,8,1" $MsComm.Handshaking = 0 $MsComm.InBufferSize = 1024 $MsComm.InputLen = 1 $MsComm.PortOpen = 1 While 1 _MsgOut("a") Sleep(2000) WEnd Func _MsgOut($str) $MsComm.OutBufferCount = 0 $MsComm.InBufferCount = 0 If $MsComm.PortOpen = True Then $MsComm.Output = $str EndIf $MsComm.InputLen = 0 EndFunc
Edited by livewire, 25 July 2005 - 02:57 PM.
#6
Posted 25 July 2005 - 03:13 PM
This code sends "RT" over COM port 2 then reads the response over COM port 2.
$MsComm = ObjCreate("MSCOMMLib.MsComm.1") $MsComm.CommPort = 2 $MsComm.Settings = "9600,N,8,1" $MsComm.Handshaking = 0 $MsComm.InBufferSize = 1024 $MsComm.InputLen = 1 $MsComm.PortOpen = 1 While 1 _MsgOut("RT" & @CR) MsgBox(0,"Testing",_MsgIn()) Sleep(2000) WEnd Func _MsgOut($str) $MsComm.OutBufferCount = 0 $MsComm.InBufferCount = 0 If $MsComm.PortOpen = True Then $MsComm.Output = $str EndIf $MsComm.InputLen = 0 EndFunc Func _MsgIn() $TIMEOUT = 1000 $nTimeCtr = 0 $sBuffer = "" Do $nTimeCtr += 1 If $MsComm.InBufferCount > 0 Then $sBuffer = $sBuffer & $MsComm.Input EndIf Sleep(500) Until StringInStr($sBuffer,@CR) OR $nTimeCtr > $TIMEOUT If $nTimeCtr < $TIMEOUT Then $nI = StringInStr($sBuffer,@CR) Return StringLeft($sBuffer,$nI) Else Return "Error" EndIf EndFunc
#7
Posted 26 July 2005 - 05:56 AM
$MsComm.CommPort = 2
$MsComm^ERROR
Error: Variable must be of type "Object".
i use the beta 1.64
Here's an example of receiving over RS232 also...if anyone cares.
This code sends "RT" over COM port 2 then reads the response over COM port 2.
Plain Text$MsComm = ObjCreate("MSCOMMLib.MsComm.1") $MsComm.CommPort = 2 $MsComm.Settings = "9600,N,8,1" $MsComm.Handshaking = 0 $MsComm.InBufferSize = 1024 $MsComm.InputLen = 1 $MsComm.PortOpen = 1 While 1 _MsgOut("RT" & @CR) MsgBox(0,"Testing",_MsgIn()) Sleep(2000) WEnd Func _MsgOut($str) $MsComm.OutBufferCount = 0 $MsComm.InBufferCount = 0 If $MsComm.PortOpen = True Then $MsComm.Output = $str EndIf $MsComm.InputLen = 0 EndFunc Func _MsgIn() $TIMEOUT = 1000 $nTimeCtr = 0 $sBuffer = "" Do $nTimeCtr += 1 If $MsComm.InBufferCount > 0 Then $sBuffer = $sBuffer & $MsComm.Input EndIf Sleep(500) Until StringInStr($sBuffer,@CR) OR $nTimeCtr > $TIMEOUT If $nTimeCtr < $TIMEOUT Then $nI = StringInStr($sBuffer,@CR) Return StringLeft($sBuffer,$nI) Else Return "Error" EndIf EndFunc
#8
Posted 26 July 2005 - 12:40 PM
I'll try copying the file used by VB to my computer without VB to see if it works.
Edited by livewire, 26 July 2005 - 01:28 PM.
#9
Posted 26 July 2005 - 01:59 PM
Yea...one of the guys on this board mentioned that you need to have Visual Basic installed...so I guess it doesn't do you any good without it...unless you can get that module from VB.
I'll try copying the file used by VB to my computer without VB to see if it works.
#10
Posted 28 July 2005 - 05:37 PM
Yea...one of the guys on this board mentioned that you need to have Visual Basic installed...so I guess it doesn't do you any good without it...unless you can get that module from VB.
I'll try copying the file used by VB to my computer without VB to see if it works.
#11
Posted 28 July 2005 - 10:39 PM
I tried with just the MSCOMM32.OCX file and didn't work without VB installed.
-Livewire
#12
Posted 29 July 2005 - 11:23 AM
You may need to register the MSCOMM32.OCX (I think VB does this for you as part of the installation process) to your system.Yea...doesn't work without VB installed...no such luck.
I tried with just the MSCOMM32.OCX file and didn't work without VB installed.
-Livewire
#13
Posted 30 July 2005 - 03:27 PM
-Livewire
#14
Posted 30 July 2005 - 03:43 PM
You will need a runtime license. See this link http://support.microsoft.com/?scid=kb;en-u...3042&sid=globalDoes anyone know how to register the MSCOMM32.OCX control to your system?
-Livewire
Cheers
Kurt
#15
Posted 02 August 2005 - 10:39 AM
vbctrls.zip 440bytes
3132 downloadsuse vbctrls.reg for licenseYou will need a runtime license. See this link http://support.microsoft.com/?scid=kb;en-u...3042&sid=global
Cheers
Kurt
#16
Posted 04 August 2005 - 03:51 AM
Here is the final thing I had to do.
**Obtained from another forum***
You need to register the component with the Windows program -REGSVR32.EXE. Use the following command:
C:\WINDOWS\SYSTEM32\REGSVR32.EXE C:\WINDOWS\SYSTEM32\MSCOMM32.OCX
If you want to unregister the component, use the following command:
C:\WINDOWS\SYSTEM32\REGSVR32.EXE /u C:\WINDOWS\SYSTEM32\MSCOMM32.OCX
#17
Posted 04 August 2005 - 07:52 AM
$MsComm1 = ObjCreate("MSCOMMLib.MsComm.1") $MsComm1.CommPort = 1 $MsComm1.Settings = "9600,N,8,1" $MsComm1.Handshaking = 0 $MsComm1.InBufferSize = 1024 $MsComm1.InputLen = 1 $MsComm2 = ObjCreate("MSCOMMLib.MsComm.1") $MsComm2.CommPort = 2 $MsComm2.Settings = "9600,N,8,1" $MsComm2.Handshaking = 0 $MsComm2.InBufferSize = 1024 $MsComm2.InputLen = 1 $MsComm1.PortOpen = 1 $MsComm2.PortOpen = 1 While 1 _MsgOut("B") Sleep(50) MsgBox(0,"Testing",_MsgIn()) Sleep(1000) WEnd Func _MsgOut($str) $MsComm1.OutBufferCount = 0 $MsComm1.InBufferCount = 0 If $MsComm1.PortOpen = True Then $MsComm1.Output = $str EndIf $MsComm1.InputLen = 0 EndFunc Func _MsgIn() Return $MsComm2.Input EndFunc
Edited by schnibble, 04 August 2005 - 07:54 AM.
#18
Posted 26 January 2006 - 02:38 PM
You may also want to look at this thread for another example as well as a free emulation of MSComm (since MSComm is not available on all machines -- a licensed component of VB6) -- Phone Dialer
vbctrls.zip 440bytes 3132 downloadsuse vbctrls.reg for license
Dale
#20
Posted 29 January 2006 - 08:34 AM
Thanks for all the info.
Here is the final thing I had to do.
**Obtained from another forum***
You need to register the component with the Windows program -REGSVR32.EXE. Use the following command:
C:\WINDOWS\SYSTEM32\REGSVR32.EXE C:\WINDOWS\SYSTEM32\MSCOMM32.OCX
If you want to unregister the component, use the following command:
C:\WINDOWS\SYSTEM32\REGSVR32.EXE /u C:\WINDOWS\SYSTEM32\MSCOMM32.OCX
And the autoit way is to just do.
Run(@ComSpec & " /c C:\WINDOWS\SYSTEM32\REGSVR32.EXE C:\WINDOWS\SYSTEM32\MSCOMM32.OCX")
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





