Jump to content

Serial Port /COM Port UDF


martin
 Share

Recommended Posts

I don't know but I think at least you should be send a carriage return after each instruction.

_CommSendstring("at+cmgf=1" & @CR)

 Sleep(100)
    _CommSendString("at+cmgs=" & "+407xxxxxx" & @CR)

 Sleep(10)
    _CommSendString($message)
    Sleep(100)
    $string = Chr(26) & @CR
_CommSendString($string,1)

 

I don't know what the quotation mark and ampersand are for after the phone number in your code so I omitted them in my example above.

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.
Link to comment
Share on other sites

Martin, once again thanks a lot for your UDF. I'm trying to use it to get a voltage from a dinamometer with an Arduino (using a 24bits ADC I get up to µv values).

I have created a nice gui to show the volatge recived and translate it to grams and newtons.

The problem is that when I'm on the loop waiting for the value the gui hanges and it doesn't respond to any button pressing (just the minimize button).

This is my last code:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GDIPlus.au3>
#include <ProgressConstants.au3>
#include <ButtonConstants.au3>
#include <WinAPI.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <IE.au3>
#include <string.au3>
#include <File.au3>
#include <EditConstants.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <ComboConstants.au3>
#include <StaticConstants.au3>
#include <resources.au3>
#include <GuiEdit.au3>
#include <CommMG.au3>


Global $X = 0
Global $buff0
Global $buffz
Global $buff000
Global $buff1
Global $Arduino = ""
Global $iDecimal = 2
Global $Value = 0

Global $convertor = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Conversion", "100") ; Conversion 1 v equals to x grams
_CommSetDllPath(@ScriptDir & "\commg.dll")
;COM Vars
Global $sportSetError = ''
Global $CMPort = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Puerto", "4") ; Port
Global $Resolucion = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Resolucion", "6") ; Decimal points of voltage recieved
Global $CmBoBaud = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Baudios", "115200") ; Baud
Global $CmboDataBits = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Bitsdedatos", "8") ; Data Bits
Global $CmBoParity = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Paridad", "none") ; Parity
Global $CmBoStop = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Stop", "1") ; Stop
Global $setflow = IniRead(@ScriptDir & "\Settings.ini", "Settings", "Flow", "2") ; Flow
Global $valorRTS = IniRead(@ScriptDir & "\Settings.ini", "Settings", "RTS", "0") ; RTS
Global $valorDTR = IniRead(@ScriptDir & "\Settings.ini", "Settings", "DTR", "0") ; DTR

;$iniciar = _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow, $valorRTS, $valorDTR)
_CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow, $valorRTS, $valorDTR)
;If $iniciar = 1 Then
;_CommSetRTS(0)
;Sleep(100)
;_CommSetDTR(0)
Sleep(100)


$mainGUI = GUICreate("DINAMOMETER", @DesktopWidth, @DesktopHeight - 35, 0, 0)
GUISetState()
GUISetState(@SW_SHOW, $mainGUI)


Global $inputvolt = GUICtrlCreateLabel("", 10, 0, 70, 18)
GUICtrlSetFont(-1, 11)


Global $buttonborrar = GUICtrlCreateButton("BORRAR", 980, 380, 100, 100, $BS_MULTILINE)
GUICtrlSetFont(-1, 16)

GUICtrlCreateLabel("F", 10, 20, 79, 100)
GUICtrlSetFont(-1, 66)

Global $inputg = GUICtrlCreateLabel("", 100, 20, 430, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)

Global $inputn = GUICtrlCreateLabel("", 540, 20, 430, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)

Global $buttontara = GUICtrlCreateButton("TARE", 980, 20, 100, 100)
GUICtrlSetFont(-1, 20)

GUICtrlCreateLabel("F1", 0, 140, 100, 100)
GUICtrlSetFont(-1, 66)

Global $inputf1g = GUICtrlCreateInput("", 100, 140, 430, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetColor(-1, 0x15006D)
GUICtrlSetBkColor(-1, 0xCCCCCC)

Global $inputf1n = GUICtrlCreateInput("", 540, 140, 430, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetColor(-1, 0x15006D)
GUICtrlSetBkColor(-1, 0xCCCCCC)

Global $buttonf1 = GUICtrlCreateButton("SET" & @CRLF & "F1", 980, 140, 100, 100, $BS_MULTILINE)
GUICtrlSetFont(-1, 20)


GUICtrlCreateLabel("F2", 0, 260, 100, 100)
GUICtrlSetFont(-1, 66)

Global $inputf2g = GUICtrlCreateInput("", 100, 260, 430, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetBkColor(-1, 0xFFFFFF)

Global $inputf2n = GUICtrlCreateInput("", 540, 260, 430, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetBkColor(-1, 0xFFFFFF)

Global $buttonf2 = GUICtrlCreateButton("SET F2", 980, 260, 100, 100, $BS_MULTILINE)
GUICtrlSetFont(-1, 20)


GUICtrlCreateLabel("L1", 100, 380, 100, 100)
GUICtrlSetFont(-1, 66)

Global $inputL1 = GUICtrlCreateInput("", 200, 380, 330, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetBkColor(-1, 0xDEFFD3)

GUICtrlCreateLabel("L2", 540, 380, 100, 100)
GUICtrlSetFont(-1, 66)

Global $inputL2 = GUICtrlCreateInput("", 640, 380, 330, 100, $ES_CENTER)
GUICtrlSetFont(-1, 66)
GUICtrlSetBkColor(-1, 0xDEFFD3)


GUICtrlCreateLabel("K", 18, 510, 129, 100)
GUICtrlSetFont(-1, 66)

Global $inputkg = GUICtrlCreateLabel("", 100, 510, 450, 88, $ES_CENTER)
GUICtrlSetFont(-1, 54)



Global $inputkn = GUICtrlCreateLabel("", 575, 510, 450, 88, $ES_CENTER)
GUICtrlSetFont(-1, 54)


GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND");to only allow number with decimals in inputs 
read()

While 1
    $msg = GUIGetMsg()
    Switch $msg

        Case $GUI_EVENT_CLOSE
            ;_CommClosePort()
            Exit

        Case $buttonf1
            $gramos = GUICtrlRead($inputg)
            GUICtrlSetData($inputf1g, $gramos)

            $gramos2 = GUICtrlRead($inputn)
            GUICtrlSetData($inputf1n, $gramos2)

        Case $buttonf2
            $gramos3 = GUICtrlRead($inputg)
            GUICtrlSetData($inputf2g, $gramos3)

            $gramos4 = GUICtrlRead($inputn)
            GUICtrlSetData($inputf2n, $gramos4)

        Case $buttonborrar
            GUICtrlSetData($inputkg, "")
            GUICtrlSetData($inputkn, "")
            GUICtrlSetData($inputf2g, "")
            GUICtrlSetData($inputf1g, "")
            GUICtrlSetData($inputf2n, "")
            GUICtrlSetData($inputf1n, "")



            If GUICtrlRead($inputL1) <> "" And GUICtrlRead($inputL2) <> "" Then
                $L1 = GUICtrlRead($inputL1)
                $L2 = GUICtrlRead($inputL2)
                If $L1 < $L2 Then
                    $h = $L2 - $L1
                Else
                    $h = $L1 - $L2
                EndIf

                $Kg = (GUICtrlRead($inputf2g) - GUICtrlRead($inputf1g)) / $h
                $Kn = (GUICtrlRead($inputf2n) - GUICtrlRead($inputf1n)) / $h
                GUICtrlSetData($inputkg, Round($Kg, 3) & " g/mm")
                GUICtrlSetData($inputkn, Round($Kn, 3) & " N/mm")
            EndIf

            ;Case  $buttontara

    EndSwitch

    Sleep(10)


WEnd


Func read();funtion to get the data from the Arduino

    Global $Arduino = _CommGetLine();_CommGetLine($sEndChar = @CR, $maxlen = 0, $maxtime = 0)
    Sleep(10)

    If @error = 0 Then
        copy($Arduino)
    Else
        read2()
    EndIf
EndFunc   ;==>read

Func read2();tried to divide the function into two to try to unlock the gui

    Global $Arduino = _CommGetLine();_CommGetLine($sEndChar = @CR, $maxlen = 0, $maxtime = 0)
    Sleep(10)

    If @error = 0 Then
        copy($Arduino)
    Else
        read()
    EndIf
EndFunc   ;==>read2


Func copy($Value);if the read or read2 funtion get a good string then refresh the labels

    ;$Arduino = _CommGetString()

    ;ConsoleWrite($Arduino)

    $ArduinoStrippedCR0 = StringStripCR($Value)
    $ArduinoStrippedCR = StringStripCR($ArduinoStrippedCR0)

    Local $Volts = StringTrimLeft($ArduinoStrippedCR, 1)

    GUICtrlSetData($inputvolt, $Volts & " v")
    Global $grams = $Volts * $convertor
    GUICtrlSetData($inputg, Round($grams, 1) & " g")
    Global $Newtons = (Round($grams, 1)) * 0.00981
    GUICtrlSetData($inputn, Round($Newtons, 3) & " N")
    Sleep(10)
    read()
EndFunc   ;==>copy

Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam); funcion para que solo se admitan numeros decimales en el campo de entrada

    Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord
    Local $iCode = BitShift($wParam, 16) ;HiWord

    If $iIDFrom = $inputL1 And $iCode = $EN_CHANGE Then

        $Read_Input = GUICtrlRead($inputL1)
        If StringRegExp($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Input = StringRegExpReplace($Read_Input, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1')
        $Point1 = StringInStr($Read_Input, ".", 0)
        $Point2 = StringInStr($Read_Input, ".", 0, 2)
        If $Point2 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point2 - 1)
        If $Point1 <> 0 Then $Read_Input = StringLeft($Read_Input, $Point1 + $iDecimal)
        GUICtrlSetData($inputL1, $Read_Input)

    EndIf

    If $iIDFrom = $inputL2 And $iCode = $EN_CHANGE Then
        $Read_Input4 = GUICtrlRead($inputL2)
        If StringRegExp($Read_Input4, '[^\d.-]|([{0-9,1}^\A-])[^\d.]') Then $Read_Input4 = StringRegExpReplace($Read_Input4, '[^\d.-]|([{0-9,1}^\A-])[^\d.]', '\1')
        $Point14 = StringInStr($Read_Input4, ".", 0)
        $Point24 = StringInStr($Read_Input4, ".", 0, 2)
        If $Point24 <> 0 Then $Read_Input4 = StringLeft($Read_Input4, $Point24 - 1)
        If $Point14 <> 0 Then $Read_Input4 = StringLeft($Read_Input4, $Point14 + $iDecimal)
        GUICtrlSetData($inputL2, $Read_Input4)
    EndIf

EndFunc   ;==>MY_WM_COMMAND

This is the last try I have done. I've also tried to create flags as the documentation for breaking functions indicate but I didn't get any better performance.

here there are some of the probes that I have done trying to get a non-flickering update for the values and a good response from the gui (it takes up to 8 seconds to respond after clicking any buton):

Tried to do all in one function

Func read()
    Do
        Do
            $Arduino = _CommGetLine();_CommGetLine($sEndChar = @CR, $maxlen = 0, $maxtime = 0)
            Sleep(100)
        Until @error = 0

        ;$Arduino = _CommGetString()

        ;ConsoleWrite($Arduino)

        $ArduinoStrippedCR0 = StringStripCR($Arduino)
        $ArduinoStrippedCR = StringStripCR($ArduinoStrippedCR0)

        Local $Volts = StringTrimLeft($ArduinoStrippedCR, 1)

        GUICtrlSetData($inputvolt, $Volts & " v")
        Global $grams = $Volts * $convertor
        GUICtrlSetData($inputg, Round($grams, 1) & " g")
        Global $Newtons = (Round($grams, 1)) * 0.00981
        GUICtrlSetData($inputn, Round($Newtons, 3) & " N")

    Until $X = 1
EndFunc   ;==>read

I have tried to insert the function inside the While:

While 1
    $msg = GUIGetMsg()
    Switch $msg

        Case $GUI_EVENT_CLOSE
            ;_CommClosePort()
            Exit

        Case $buttonf1
            $gramos = GUICtrlRead($inputg)
            GUICtrlSetData($inputf1g, $gramos)

            $gramos2 = GUICtrlRead($inputn)
            GUICtrlSetData($inputf1n, $gramos2)

        Case $buttonf2
            $gramos3 = GUICtrlRead($inputg)
            GUICtrlSetData($inputf2g, $gramos3)

            $gramos4 = GUICtrlRead($inputn)
            GUICtrlSetData($inputf2n, $gramos4)

        Case $buttonborrar
            GUICtrlSetData($inputkg, "")
            GUICtrlSetData($inputkn, "")
            GUICtrlSetData($inputf2g, "")
            GUICtrlSetData($inputf1g, "")
            GUICtrlSetData($inputf2n, "")
            GUICtrlSetData($inputf1n, "")



            If GUICtrlRead($inputL1) <> "" And GUICtrlRead($inputL2) <> "" Then
                $L1 = GUICtrlRead($inputL1)
                $L2 = GUICtrlRead($inputL2)
                If $L1 < $L2 Then
                    $h = $L2 - $L1
                Else
                    $h = $L1 - $L2
                EndIf

                $Kg = (GUICtrlRead($inputf2g) - GUICtrlRead($inputf1g)) / $h
                $Kn = (GUICtrlRead($inputf2n) - GUICtrlRead($inputf1n)) / $h
                GUICtrlSetData($inputkg, Round($Kg, 3) & " g/mm")
                GUICtrlSetData($inputkn, Round($Kn, 3) & " N/mm")
            EndIf

            ;Case  $buttontara

    EndSwitch

    $Arduino = _CommGetLine(@CR, 0, 200);_CommGetLine($sEndChar = @CR, $maxlen = 0, $maxtime = 0)
    Sleep(20)
    If @error = 0 Then

        ;$Arduino = _CommGetString()

        ;ConsoleWrite($Arduino)

        $ArduinoStrippedCR0 = StringStripCR($Arduino)
        $ArduinoStrippedCR = StringStripCR($ArduinoStrippedCR0)

        Local $Volts = StringTrimLeft($ArduinoStrippedCR, 1)

        GUICtrlSetData($inputvolt, $Volts & " v")
        Global $grams = $Volts * $convertor
        GUICtrlSetData($inputg, Round($grams, 1) & " g")
        Global $Newtons = (Round($grams, 1)) * 0.00981
        GUICtrlSetData($inputn, Round($Newtons, 3) & " N")
    EndIf
    Sleep(10)
WEnd

I have tried to insert the While inside the function and also to tried to use the parameters of the _Commgetline:

$Arduino = _CommGetLine(@CR, 0, 600)

There is no way of getting a non flickering label update and a fast responding gui.

Any idea? I though that I wasn't as newbie to get stuck in a loop problem like this.

Greets from Barcelona

 

EDIT:

I solved it. Thanks again for the UDF

Edited by adolfito121
Link to comment
Share on other sites

Hello everybody,

I'm starting using CommMG.au3 and it seems really helpful!

I need though to set data bits to 6 and I'm getting an undefined "!Error: 1" message in AutoIt console.

I tried to set DataBits to 6 in C++ and it's working, so is it a limit of CommMG.au3?

Can it be extended to include 6 DataBits somehow?

Thanks and have a nice day,

Virgus

BTW I have another question: is there available an extension of CommListPorts

where I can get a returntype parameter for Com ports friendly names?

Edited by Virgus
Link to comment
Share on other sites

Virgus,

I'll have a look in 2 days (9th March) and get back to you.

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.
Link to comment
Share on other sites

Apologies for the delay.

The link on the first page of this thread will get dll version 2.82 which allows for data bits 4,5,6,7 and 8. Previously I had only allowed for 7 or 8 data bits, I suppose because that's all I've ever used.

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.
Link to comment
Share on other sites

  • 2 weeks later...

Hello Martin,

I just found out a small problem with 6bits transmission.

I'm using Parity None, 1 Stop bit, Flow none, RTS & DTR off.

I sent twice a testing pattern like 0x15002A3F; in binary it is:

h15 = b0.101010.1
h00 = b0.000000.1
h2A = b0.010101.1
h3F = b0.111111.1
 

I included the start bit and the stop bit to make it easy to follow the snapshot I attached

(where the first row is the TX output, the second is the TX inverted signal).

So if you have a look at this snapshot I'm getting an extra 0 (in red) is added just before the stop bit (in blue):

h15 = b0.101010.0.1
h00 = b0.000000.0.1
h2A = b0.010101.0.1
h3F = b0.111111.0.1
 

Summarizing 6 data bits transmission is in reality 7 bits data transmission.

I tested from 5 to 8 and everything seems fine on data bits other than 6...

Please have a look and if I might have done something wrong

it just means I need to sleep more at night instead of doing my serial tests ;-)

Cheers,

V.

post-54962-0-89100300-1395577982_thumb.g

Link to comment
Share on other sites

You are correct Virgus. My apologies for the error. Version 2.83 of the dll corrects this and is ready to download.

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.
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Hello Martin,

I'm sorry to write you again (and a bit late) about this issue but with the last release you updated

when I set databits < 7 then I get an error message (once it reported that the serial port was not available

but clearly it was available with 7 or 8 bits).

Could you please give a look to this?

Kind regards,

Virgus

 

post-54962-0-73656400-1397693741_thumb.j

Link to comment
Share on other sites

  • 3 weeks later...

I was steered here since I posted a CommMG question on the general forum.

I'm trying to monitor a serial device that uses 9 bit data - I suppose it's a complete re-architecturing, right?  To make things worse, I need to use a USB dongle version of the serial port.

Link to comment
Share on other sites

There is AFAIK no such thing as a 9 data bit serial device to be used on USB or serial port.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

At least it's the job of a serial controller (like the 8250 and derivatives) to check the required parity on input, report an error if it's incorrect and produce the valid parity on output.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

What's your actual problem exactly? You talked about 9-bit data, now about detecting parity errors. Once the correct settings are found and used, your input will work.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

That's why I asked if Parity Error was check-able.  As far as I can tell from looking at CommMG, all errors are lumped together.

My actual problem is monitoring a SEATALK bus, which is a single-wire bi-directional serial line that uses the ninth bit to mark "start of message".  It's collision detection relies on framing errors to some extent, so a universal @ERROR will create problems.

I've already coded a PIC processor to do the job, so I guess I'm giving up with the "easy" solution...

Link to comment
Share on other sites

Ha, this weird use! Ask Martin if there is a function in his DLL you can use for that, else look at >this alternative solution.

Of course a dedicated PIC will do the job as well.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • 3 months later...

Great appreciation to Martin! This UDF saves a lot of my developing time. But it just encountered a problem of using it. While I am using terminal app such as SecureCRT and Hyperterminal to connect to my product, everything is fine. And I am just developing a test program to get access  to my product. Firstly I used the "CommgExample.au3" to see whether if the function is okay. The problem occurs. When I input a command through the example, it received garbled message as a return.(please refer to the attach image) For verifying this issue. I have used a virtual serial port app to simulate a virtual port so that I can make connection between CommgExample.au3 and SecureCRT. I found that the function is okay and the characters are fine. I cannot not figure what's the root cause for this issue. Hope there's someone has the same experience and could point it out for me. Thanks!!

 

CommgExample.au3 with my prodcut

 x0Ggnb.png

 

CommgExample.au3 with SecureCRT

qnZMNi.png

Edited by BernyHsu
Link to comment
Share on other sites

Great appreciation to Martin! This UDF saves a lot of my developing time. But it just encountered a problem of using it. While I am using terminal app such as SecureCRT and Hyperterminal to connect to my product, everything is fine. And I am just developing a test program to get access  to my product. Firstly I used the "CommgExample.au3" to see whether if the function is okay. The problem occurs. When I input a command through the example, it received garbled message as a return.(please refer to the attach image) For verifying this issue. I have used a virtual serial port app to simulate a virtual port so that I can make connection between CommgExample.au3 and SecureCRT. I found that the function is okay and the characters are fine. I cannot not figure what's the root cause for this issue. Hope there's someone has the same experience and could point it out for me. Thanks!!

 

CommgExample.au3 with my prodcut

 x0Ggnb.png

 

CommgExample.au3 with SecureCRT

qnZMNi.png

Hi BernyHsu,

Can you tell me the settings for the serial port? The number of data bits, parity etc.

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.
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...