Jump to content

Recommended Posts

Posted

@Martin

Can you compile a 64 bit version?

Sorry, I cannot.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

OK , Can I?

No because I have written it in Delphi and there is no 64 bit version yet,( maybe never).

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
  • 3 weeks later...
Posted

Hi!

I recive a blank MsgBox with this script, however it should list some ports instead. What's wrong with it?

#include <CommMG.au3>

MsgBox("", _CommListPorts(), _CommListPorts())

the dll is in the same dir as the executable, tried it on 32bit win7 and XP.

Posted (edited)

Hi!

I recive a blank MsgBox with this script, however it should list some ports instead. What's wrong with it?

#include <CommMG.au3>

MsgBox("", _CommListPorts(), _CommListPorts())

the dll is in the same dir as the executable, tried it on 32bit win7 and XP.

Nothing wrong with it. Difficult to know if there was an error though so try this

#include <CommMG.au3>

$List = _CommListPorts()
if @error = 2 then
    MsgBox(262144,"Error 2:"," Cannot open dll" )
elseif @error = 1 then
 MsgBox(262144,"Error 1:","No ports listed")
elseif $List = '' then
 MsgBox(262144,"NONE","There are no COM ports on this PC")
else
 MsgBox(262144,"COM ports:",$List)
endif

On XP I get COM1|COM2 on the PC I'm using.

EDIT: BTW, if still problems can you tell me what the output from this is

msgBox(262144,"Versions", "dll = " & _CommGetVersion(1) & @CRLF & "UDF = " & _CommGetVersion(2))
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

Hi,

I see serial functions are still interesting.

here is a new version for serial communication with RS485 control and reception of NUL characters.

Works fine for me.

I included also some CRC and BCC functions in the example

Uwe

Looks good Uwe.

You should start a new thread in example scripts with that, you might be surprised at the interest as I was with my udf, and yours has the advantage of not needing a dll.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted (edited)

Thank you for the advice,

I deleted my post , and I will post an improved version in another thread (look for serial and kernel32) or here

Uwe

Edited by Uwe
Posted

hi

a simple question about this useful tool,

I need to make a rs232 relay, could i use this udf to set 0/+5V on a pin (i guess on pin 3 "Data send")?

Posted

hi

a simple question about this useful tool,

I need to make a rs232 relay, could i use this udf to set 0/+5V on a pin (i guess on pin 3 "Data send")?

You would need to use a handshaking line not a data line.

There is a _CommSetDTR and a _CommSetRTS function, but make sure you do not try to drive a relay directlly or will will probably damage you COM port circuitry.

It would be better to buy an RS232 relay output board, or a USB I/O interface.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

Thanks for the reply.

I need to activate an IC pin, no high electric consume

Ok, fine.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

i tried with this:

#include 'CommMG.au3'
$a= " "

_CommSetPort(1, $a, 50, 8, 0, 1, 1)
_CommSwitch(1)
_CommSetRTS(1)

But my voltimeter still marks nothing on PINs 5 and 7 (GND and RTS)

What am i doing wrong?

Thanks

Posted (edited)

i tried with this:

#include 'CommMG.au3'
$a= " "

_CommSetPort(1, $a, 50, 8, 0, 1, 1)
_CommSwitch(1)
_CommSetRTS(1)

But my voltimeter still marks nothing on PINs 5 and 7 (GND and RTS)

What am i doing wrong?

Thanks

I don't know and I've never tried those functions I'm afaid and I don't know if anyone has used them. I don't have time to look at it now but try setting the flow to 0 for hardware hanshake in _CommSetPort. If that doesn't help let me know and I will look at it. Try DTR as well.

These functions work but only if you do not select hardware handshaking. You must select either NONE or XON/XOFF for flow control.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

Hi guys, I'm still trying to use this UDF for RFID.

The setting for RFID is :

BaudRate : 38400

Parity : even

Data bit : 7

Stop bit : 2

When i send command "00RDSTAA0001" to read a single tag, nothing is returned. Am i doing something wrong?

BTW, I'm using OMRON RFID kit

AUTOIT[sup] I'm lovin' it![/sup]

Posted

Hi guys, I'm still trying to use this UDF for RFID.

The setting for RFID is :

BaudRate : 38400

Parity : even

Data bit : 7

Stop bit : 2

When i send command "00RDSTAA0001" to read a single tag, nothing is returned. Am i doing something wrong?

BTW, I'm using OMRON RFID kit

I know nothing about the Omron kit. Maybe you have forgotten to add & @CR to the end of the line.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
  • 2 weeks later...
Posted

Hello!

I have Windows 7 x64 + AutoIt v3.3.6.0.

If I compile CommgExample.au3

>Running:(3.3.6.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "D:\CommgExample.au3"

CommgExample.au3 (178) : ==> Subscript used with non-Array variable.:

For $pl = 1 To $portlist[0]

For $pl = 1 To $portlist^ ERROR

In my scripts function _CommListPorts does not work.

I have only port 0.

Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

Posted

Hello!

I have Windows 7 x64 + AutoIt v3.3.6.0.

If I compile CommgExample.au3

>Running:(3.3.6.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "D:\CommgExample.au3"

CommgExample.au3 (178) : ==> Subscript used with non-Array variable.:

For $pl = 1 To $portlist[0]

For $pl = 1 To $portlist^ ERROR

In my scripts function _CommListPorts does not work.

I have only port 0.

I do not have time to examine it now but it could be an error in my dll or in my UDF.

Can you try changing

$portlist = _CommListPorts(0);find the available COM ports and write them into the ports combo
    If @error = 1 Then
    MsgBox(0, 'trouble getting portlist', 'Program will terminate!')
    Exit
    EndIf


    For $pl = 1 To $portlist[0]
    GUICtrlSetData($CmboPortsAvailable, $portlist[$pl]);_CommListPorts())
    Next

to

$portlist = _CommListPorts(1);(1) was (0)
    If @error = 1 Then
    MsgBox(0, 'trouble getting portlist', 'Program will terminate!')
    Exit
    EndIf

if StringInStr($portlist,"|") then
 $portlist = StringSplit($portlist,"|")
    For $pl = 1 To $portlist[0]
    GUICtrlSetData($CmboPortsAvailable, $portlist[$pl]);_CommListPorts())
    Next
 Else
    GUICtrlSetData($CmboPortsAvailable, $portlist)
 EndIf

And let me know what difference it makes.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted (edited)

Hello Martin!

Now script is running but still I have only port 0.

In my computer I have 6 serial ports (COM port).

post-29400-1268382116216_thumb.jpg

Edited by kmeleon

Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

Posted (edited)

Hello Martin!

Now script is running but still I have only port 0.

In my computer I have 6 serial ports (COM port).

So does that mean I misunderstood your previous post, or have you added 5 serial ports since that post?

Are these 5 other ports on something like a PCI card or usb? Do you see all 6 ports in device manager?

EDIT: I know close to nothing about W7, but could you try running the program in compatibility mode for XP SP3?

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

I seem to be having trouble with the '_CommSendByteArray' function. I have tried a few examples from this post, and all appear to fail (-1). '_CommSendByte' works fine.

Here is one of the examples I have tried:

#include <CommMg.au3>
$Numbytes1 = 16;say we have 16 bytes

$Struct1 = DllStructCreate("byte[" & $Numbytes1 & "]")

For $n = 1 To 16;put some random numbers in the struct
    DllStructSetData($Struct1, 1, Random(0, 255, 1), $n)
Next

;send the bytes
_CommSendByteArray(DllStructGetPtr($Struct1), $Numbytes1, 1)
if @error then MsgBox(0, 'ERROR', '_CommSendByteArrray failed')

I am using AutoIt v3.3.4.0 on WinXP SP3.

Any thoughts?

Thanks for the great stuff!

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