Jump to content



Photo

RS232?


  • Please log in to reply
31 replies to this topic

#1 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 22 July 2005 - 08:05 PM

Does anyone know how to do serial communication over RS232 with AutoIt. Is this possible with COM?

-Livewire





#2 MSLx Fanboy

MSLx Fanboy

    Local $Clue = 0

  • Active Members
  • PipPipPipPipPipPip
  • 1,046 posts

Posted 22 July 2005 - 08:47 PM

What about just opening a Telnet session with Hyper terminal, and just handle it like that...maybe Hyperterm has a COM interface?

Edit: Not telnet, just a connection via COM1 or 2...

Edited by MSLx Fanboy, 22 July 2005 - 08:47 PM.

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

#3 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 22 July 2005 - 10:21 PM

I could do that...I was just wondering if someone figured out how to use the COM component where I could just use ObjCreate(MSComm) or something.

-Livewire

#4 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 25 July 2005 - 01:01 PM

I guess I'll take this as a "no".

#5 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 25 July 2005 - 02:28 PM

Freakin' awesome...figured it out...props to Valik for pointing the OLE/COM Viewer.

Here is an example of sending out the letter 'a' over COM port 2 every 2 seconds:
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("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 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 25 July 2005 - 03:13 PM

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


#7 schnibble

schnibble

    Seeker

  • Active Members
  • 26 posts

Posted 26 July 2005 - 05:56 AM

i get

$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

<{POST_SNAPBACK}>



#8 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 26 July 2005 - 12:40 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.

Edited by livewire, 26 July 2005 - 01:28 PM.


#9 schnibble

schnibble

    Seeker

  • Active Members
  • 26 posts

Posted 26 July 2005 - 01:59 PM

ok, thank you

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.

<{POST_SNAPBACK}>



#10 schnibble

schnibble

    Seeker

  • Active Members
  • 26 posts

Posted 28 July 2005 - 05:37 PM

any news?

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.

<{POST_SNAPBACK}>



#11 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 28 July 2005 - 10:39 PM

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

#12 Confuzzled

Confuzzled

    Mouse moved. Please restart Windows for changes to take effect.

  • Active Members
  • PipPipPipPipPipPip
  • 1,000 posts

Posted 29 July 2005 - 11:23 AM

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

<{POST_SNAPBACK}>

You may need to register the MSCOMM32.OCX (I think VB does this for you as part of the installation process) to your system.

#13 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 30 July 2005 - 03:27 PM

Does anyone know how to register the MSCOMM32.OCX control to your system?

-Livewire

#14 /dev/null

/dev/null

    Universalist

  • MVPs
  • 2,946 posts

Posted 30 July 2005 - 03:43 PM

Does anyone know how to register the MSCOMM32.OCX control to your system?

-Livewire

<{POST_SNAPBACK}>

You will need a runtime license. See this link http://support.microsoft.com/?scid=kb;en-u...3042&sid=global

Cheers
Kurt
__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

#15 schnibble

schnibble

    Seeker

  • Active Members
  • 26 posts

Posted 02 August 2005 - 10:39 AM

Attached File  vbctrls.zip   440bytes   3132 downloadsuse vbctrls.reg for license

You will need a runtime license. See this link http://support.microsoft.com/?scid=kb;en-u...3042&sid=global

Cheers
Kurt

<{POST_SNAPBACK}>



#16 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 04 August 2005 - 03:51 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

#17 schnibble

schnibble

    Seeker

  • Active Members
  • 26 posts

Posted 04 August 2005 - 07:52 AM

use it with null-modem cable :whistle:
Plain Text         
$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 DaleHohm

DaleHohm

    Think of IE as an API...

  • MVPs
  • 5,888 posts

Posted 26 January 2006 - 02:38 PM

Attached File  vbctrls.zip   440bytes   3132 downloadsuse vbctrls.reg for license

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

Dale
IE.au3 issues with Vista - Workarounds, Automate input type=file (Related)SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=YFree Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model,Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbeddedFind and harvest Enum constants for COM codeAutoIt Snippets Database - you too can contribute!Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your troubleDoesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

#19 livewire

livewire

    Polymath

  • Active Members
  • PipPipPipPip
  • 208 posts

Posted 28 January 2006 - 08:15 PM

Go here to get MSCOMM32.OCX and see additional information.

#20 Adam1213

Adam1213

    Adventurer

  • Active Members
  • PipPip
  • 133 posts

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