Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 15 of 31
  1. #1
    Join Date
    Jul 2009
    Posts
    122

    Arrow Free: Serial Port Action plugin

    Hi friends, firstly sorry from my english, i'm spanish but i try to do this in english.

    Now AMS can use COM ports with this action plugin, i'm working on parallel port action plugin now.

    The plugin is made by action plugin compiler by reteset.

    Your need LuaCom, get it from http://www.icynorth.com/luacom/index.html and be sure that is activated in your project

    You already need NetComm.ocx ActiveX control, get it from http://home.comcast.net/~hardandsoftware/NETCommOCX.htm be sure that is registered in the machine, if not, the plugin implements a function to register this control (vista and x64 users need register mscomm32.ocx, get it from http://www.yes-tele.com/mscomm.html )

    You can use a timer to know if the port buffer countais data, for example Timer Object Plugin from Amswaves rules! get it from http://www.amswaves.com/index.php?op...d=45&Itemid=55

    Basic example

    Code:
    c=SerialPort.Init()
    if(c==false) then
    Dialog.Message("Notice", "No encuentra control", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    SerialPort.SetPort(1)
    SerialPort.Open();
    SerialPort.Output("ATDT950346259;",true)
    SerialPort.Termiate()
    You can recive with timer each 100ms with:

    Code:
    if(SerialPort.IsOpen()==true) then
    if (SerialPort.BufferCount()==0) then
    --do nothing
    else
    buffer=SerialPort.Input();
    end end
    You can get the list of avalible ports with ListAvaliblePorts

    I'm electronic engineer and the use of ports is very useful, it's compatible with all com ports, emulated, usb to serial, rs485, rs232, gps, mobile phones...

    Best regards
    Attached Files

  2. #2
    Join Date
    Jul 2009
    Posts
    122

    Live demo

    You can download this demo that i made

    This is a Serial Port monitor, like hyperterm, i'm now sending AT commands to my nokia via bluethoot serial and I read SMS, set alarms, set options, send sms, make calls...

    http://www.megaupload.com/?d=7XDLBME0

  3. #3
    Join Date
    Oct 2008
    Posts
    21

    Thumbs up

    Wow! thank for nice plugin this good !!

  4. #4
    Join Date
    Jul 2009
    Posts
    122

    Source code

    If anybody like to know how work and perform this plugin, this is the source code

    SerialPort.lua

    PHP Code:
    SerialPort = {Stored = {}};
    -------------------------------------------------------
    SerialPort.Version 1.0;
    -------------------------------------------------------
    function 
    SerialPort.Init()
    com=luacom.CreateObject("NETCommOCX.NETComm")
    if (
    com==nilthen
    return false
    else
    return 
    true
    end
    end
    -------------------------------------------------------
    function 
    SerialPort.Termiate()
    com.PortOpen=false
    com
    =nil
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.Open()
    com.PortOpen=true
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.IsOpen()
    return 
    com.PortOpen
    end
    -------------------------------------------------------
    function 
    SerialPort.Close()
    com.PortOpen=false
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.SetSettings(nBauds,nParity,nDatabit,nStopbit,nFlowcontrol)
    com.Settings=nBauds..nParity..nDatabit..nStopbit
    com
    .Handshaking=nFlowcontrol
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.SetPort(nPort)
    com.CommPort=nPort
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.ListAvaliblePorts(nStart,nEnd)

    ports={}

    for 
    count nStartnEnd do
        
    com.CommPort=count
        com
    .PortOpen=true
        
    if (com.PortOpen==truethen
            Table
    .Insert(ports1count);
        
    end
        com
    .PortOpen=false
    end

    return ports
    end
    -------------------------------------------------------
    function 
    SerialPort.SetRTS(nRTS)
    com.RTSEnable=nRTS
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.SetDTR(nDTR)
    com.DTREnable=nDTR
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.GetRTS()
    return 
    com.RTSEnable
    end
    -------------------------------------------------------
    function 
    SerialPort.GetDTR()
    return 
    com.DTREnable
    end
    -------------------------------------------------------
    function 
    SerialPort.Output(sOutput,nBreak)
    if (
    nBreak==truethen
    sOutput
    =sOutput..String.Char(13)
    end
    com
    .Output=sOutput
    return true
    end
    -------------------------------------------------------
    function 
    SerialPort.Input()
    return 
    com.InputData
    end
    -------------------------------------------------------
    function 
    SerialPort.BufferCount()
    return 
    com.InBufferCount
    end
    -------------------------------------------------------
    function 
    SerialPort.InputLen()
    return 
    com.InputLen
    end
    -------------------------------------------------------
    function 
    SerialPort.RegisterMscomm(sObject)
    System.RegisterActiveX(sObject);
    return 
    true
    end
    -------------------------------------------------------
    function 
    SerialPort.RegisterNetComm(sObject)
    System.RegisterActiveX(sObject);
    return 
    true
    end 
    SerialPort.xml

    PHP Code:
    <ActionTemplates>

    <
    Action>
    <
    Name>SerialPort.Init</Name>
    <
    Description>Init the driver (LuaCom is neededreturns true if possible or false if notYou can register netcomm and mscomm if needed</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    </
    Action>


    <
    Action>
    <
    Name>SerialPort.Terminate</Name>
    <
    Description>Stop the driverclose opened ports and free Com Object</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    </
    Action>


    <
    Action>
    <
    Name>SerialPort.Open</Name>
    <
    Description>Open the working com port (use setport)</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.IsOpen</Name>
    <
    Description>Pool the driver and return port status</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    </
    Action>


    <
    Action>
    <
    Name>SerialPort.Close</Name>
    <
    Description>Close opened port</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    </
    Action>


    <
    Action>
    <
    Name>SerialPort.SetSettings</Name>
    <
    Description>Set settings for por connection</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>Baud rate</Name>
    <
    Description>avalible 110 300 600 1200 2400 9600 14400 19200 28800 38400 56000 128000 256000</Description>
    <
    Type>number</Type>
    <Default>
    9600</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "9600"</Default>
    <
    DataType>number</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>

    <
    Arg>
    <
    Name>Parity</Name>
    <
    Description>NNone EEven MMark OOdd SSpace</Description>
    <
    Type>string</Type>
    <Default>
    N</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "N"</Default>
    <
    DataType>string</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>

    <
    Arg>
    <
    Name>Databits</Name>
    <
    Description>avalible 45678</Description>
    <
    Type>number</Type>
    <Default>
    8</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "8"</Default>
    <
    DataType>number</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>

    <
    Arg>
    <
    Name>Stopbits</Name>
    <
    Description>avalible 11.52</Description>
    <
    Type>number</Type>
    <Default>
    1</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "1"</Default>
    <
    DataType>number</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>

    <
    Arg>
    <
    Name>Flowcontrol Handshacking</Name>
    <
    Description>0None 1XON/XOFF 2RTS/CTS 3RTS XON/XOFF</Description>
    <
    Type>number</Type>
    <Default>
    0</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "0"</Default>
    <
    DataType>number</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>



    <
    Action>
    <
    Name>SerialPort.SetPort</Name>
    <
    Description>Set working port before set settings and open</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>Port</Name>
    <
    Description>Port number</Description>
    <
    Type>number</Type>
    <Default>
    1</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "1"</Default>
    <
    DataType>number</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.ListAvaliblePorts</Name>
    <
    Description>Return a table with avalible ports in the maxmin range</Description>
    <
    ReturnValueType>table</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>PortStart</Name>
    <
    Description>starting number port</Description>
    <
    Type>number</Type>
    <Default>
    1</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "1"</Default>
    <
    DataType>number</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    <
    Arg>
    <
    Name>PortEnd</Name>
    <
    Description>end number port</Description>
    <
    Type>number</Type>
    <Default>
    16</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "16"</Default>
    <
    DataType>number</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>


    <
    Action>
    <
    Name>SerialPort.SetRTS</Name>
    <
    Description>set rts line</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>RTS</Name>
    <
    Description>state of RTS line</Description>
    <
    Type>boolean</Type>
    <Default>
    true</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "true"</Default>
    <
    DataType>boolean</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.SetDTR</Name>
    <
    Description>set DTR line</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>DTR</Name>
    <
    Description>state of DTR line</Description>
    <
    Type>boolean</Type>
    <Default>
    true</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "true"</Default>
    <
    DataType>boolean</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.GetRTS</Name>
    <
    Description>get rts state</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.GetDTR</Name>
    <
    Description>get DTR state</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.Output</Name>
    <
    Description>Oiutput buffer to the serial port</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>Output</Name>
    <
    Description>String to output</Description>
    <
    Type>sting</Type>
    <Default></Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    ""</Default>
    <
    DataType>string</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    <
    Arg>
    <
    Name>CRLF</Name>
    <
    Description>send  CR LF at the end of output</Description>
    <
    Type>boolean</Type>
    <Default>
    true</Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    "true"</Default>
    <
    DataType>boolean</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>


    <
    Action>
    <
    Name>SerialPort.Input</Name>
    <
    Description>Get Input buffer</Description>
    <
    ReturnValueType>string</ReturnValueType>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.BufferCount</Name>
    <
    Description>return the buffer stored</Description>
    <
    ReturnValueType>number</ReturnValueType>
    </
    Action>

    <
    Action>
    <
    Name>SerialPort.InputLen</Name>
    <
    Description>Len of Input</Description>
    <
    ReturnValueType>number</ReturnValueType>
    </
    Action>



    <
    Action>
    <
    Name>SerialPort.RegisterMscomm</Name>
    <
    Description>Register mscomm32.ocx</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>File</Name>
    <
    Description>Ocx control file</Description>
    <
    Type>file</Type>
    <Default></Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    ""</Default>
    <
    DataType>file</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>


    <
    Action>
    <
    Name>SerialPort.RegisterNetComm</Name>
    <
    Description>Register netcomm.ocx</Description>
    <
    ReturnValueType>boolean</ReturnValueType>
    <
    Arguments>
    <
    Arg>
    <
    Name>File</Name>
    <
    Description>Ocx control file</Description>
    <
    Type>file</Type>
    <Default></Default>
    <
    Required>1</Required>
    <
    EasyMode>
    <Default>
    ""</Default>
    <
    DataType>file</DataType>
    <
    Constraints>none</Constraints>
    </
    EasyMode>
    </
    Arg>
    </
    Arguments>
    </
    Action>



    </
    ActionTemplates
    Best regards for all

  5. #5
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Thank you, quite educative
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  6. #6
    Join Date
    Jul 2009
    Posts
    122

    Using MsComm32 native driver instread netcomm

    If you want use mscomm control instread netcomm, you can do changing a few lines of code, but this have several problems because mscomm only work in unlicesend mode with VisualStudio, it can be shows some errors of execution and work slow, but the control is native of windows

    only need change

    com=luacom.CreateObject("NETCommOCX.NETComm")

    by

    com=luacom.CreateObject("MSCommLib.MSComm")

    And solve license problems adding this to registry

    Code:
    REGEDIT
    HKEY_CLASSES_ROOT\Licenses = Licensing: Copying the keys may be a violation of established copyrights.
    
    // The 16 bit and 32-bit OCX Professional license follows:
    HKEY_CLASSES_ROOT\Licenses\DB4C0D00-400B-101B-A3C9-08002B2F49FB = mgkgtgnnmnmninigthkgogggvmkhinjggnvm
    							
    // The 32 bit OCX Professional license follows:
    HKEY_CLASSES_ROOT\Licenses\7BC20EDC-4A42-101B-A3C9-08002B2F49FB = gifblihbhiiihbciocfbkifbqcfcdiebbiqh
    
    // spin32 DB key
    // anibtn DB key
    // gauge  7B key
    // grid   DB key
    // keysta DB key
    // msoutl DB key
    // threed DB key

    Dont forget that InputData() from netcomm now need be Input(), changing
    Code:
    function SerialPort.Input() 
    return com.InputData 
    end
    by
    Code:
    function SerialPort.Input() 
    return com.Input 
    end
    I'm working now in onComm event for debugging and implement an script id for control more of one ports in the same script

    thanks for interresting on this

  7. #7
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Looking good, thanks for the effort mate
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  8. #8
    Join Date
    Jul 2009
    Posts
    122

    New version

    Hi all, I have new version with possibility to control many com ports at the same time.

    The plugin now expect an stream to swith driver

    On startup:
    Code:
    com1=SerialPort.Init(1)
    com2=SerialPort.Init(2)
    com3=SerialPort.Init(3)
    
    SerialPort.SetPort(1,1)
    SerialPort.SetPort(2,2)
    SerialPort.SetPort(3,3)
    
    SerialPort.Open(1)
    SerialPort.Open(2)
    SerialPort.Open(3)
    
    --Now COM1, COM2 and COM3 are opened
    
    readed=SerialPort.Input(2)
    SerialPort.Output(1, readed, false)
    SerialPort.Output(3, readed, false)
    
    --read COM2 and put into COM1 and COM3
    On shutdown

    Code:
    SerialPort.TerminateAll()
    And now, If NetComm isn't installed, the app try to use mscomm

    This is the sorce code

    Code:
    SerialPort.lua
    
    
    SerialPort = {Stored = {}};
    axComPort={}
    -------------------------------------------------------
    SerialPort.Version = 1.1;
    -------------------------------------------------------
    function SerialPort.Init(uuid)
    axComPort[uuid]=luacom.CreateObject("NETCommOCX.NETComm")
    netms=0
    if (axComPort[uuid]==nil) then
    	axComPort[uuid]=luacom.CreateObject("MSCommLib.MSComm")
    	if (axComPort[uuid]==nil) then
    		return false
    	else
    		netms=1
    		return true
    	end
    else
    	return true
    end
    end
    -------------------------------------------------------
    function SerialPort.TermiateAll()
    uuids = Table.Count(axComPort);
    for count = 1, uuids do
    axComPort[count].PortOpen=false
    end
    axComPort=nil
    end
    -------------------------------------------------------
    function SerialPort.Termiate(uuid)
    axComPort[uuid].PortOpen=false
    axComPort[uuid]=nil
    end
    -------------------------------------------------------
    function SerialPort.Open(uuid)
    axComPort[uuid].PortOpen=true
    end
    -------------------------------------------------------
    function SerialPort.IsOpen(uuid)
    return axComPort[uuid].PortOpen
    end
    -------------------------------------------------------
    function SerialPort.Close(uuid)
    axComPort[uuid].PortOpen=false
    end
    -------------------------------------------------------
    function SerialPort.SetSettings(uuid,nBauds,nParity,nDatabit,nStopbit,nFlowcontrol)
    axComPort[uuid].Settings=nBauds..nParity..nDatabit..nStopbit..nFlowcontrol
    end
    -------------------------------------------------------
    function SerialPort.SetPort(uuid,nPort)
    axComPort[uuid].CommPort=nPort
    end
    -------------------------------------------------------
    function SerialPort.ListAvaliblePorts(uuid,nStart,nEnd)
    
    ports={}
    
    for count = nStart, nEnd do
    	axComPort[uuid].CommPort=count
    	axComPort[uuid].PortOpen=true
    	if (axComPort[uuid].PortOpen==true) then
    		Table.Insert(ports, 1, count);
    	end
    	axComPort[uuid].PortOpen=false
    end
    
    return ports
    end
    -------------------------------------------------------
    function SerialPort.SetRTS(uuid,nRTS)
    axComPort[uuid].RTSEnable=nRTS
    end
    -------------------------------------------------------
    function SerialPort.SetDTR(uuid,nDTR)
    axComPort[uuid].DTREnable=nDTR
    end
    -------------------------------------------------------
    function SerialPort.GetRTS(uuid)
    return axComPort[uuid].RTSEnable
    end
    -------------------------------------------------------
    function SerialPort.GetDTR(uuid)
    return axComPort[uuid].DTREnable
    end
    -------------------------------------------------------
    function SerialPort.Output(uuid,sOutput,nBreak)
    if (nBreak==true) then
    sOutput=sOutput..String.Char(13)
    end
    axComPort[uuid].Output=sOutput
    end
    -------------------------------------------------------
    function SerialPort.Input(uuid)
    if (netms==1) then
    return axComPort[uuid].Input
    else
    return axComPort[uuid].InputData
    end end
    -------------------------------------------------------
    function SerialPort.BufferCount(uuid)
    return axComPort[uuid].InBufferCount
    end
    -------------------------------------------------------
    function SerialPort.InputLen(uuid)
    return axComPort[uuid].InputLen
    end
    -------------------------------------------------------
    function SerialPort.RegisterMscomm(sObject)
    System.RegisterActiveX(sObject);
    
    end
    -------------------------------------------------------
    function SerialPort.RegisterNetComm(sObject)
    System.RegisterActiveX(sObject);
    end
    
    
    SerialPort.xml
    
    
    <ActionTemplates>
    
    <Action>
    <Name>SerialPort.Init</Name>
    <Description>Init the driver (LuaCom is needed) returns true if possible or false if not. You can register netcomm and mscomm if needed</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    <Action>
    <Name>SerialPort.Terminate</Name>
    <Description>close opened ports and free Com Object</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    <Action>
    <Name>SerialPort.TerminateAll</Name>
    <Description>Stop the driver, close opened ports and free Com Object</Description>
    <ReturnValueType>boolean</ReturnValueType>
    </Action>
    
    
    <Action>
    <Name>SerialPort.Open</Name>
    <Description>Open the working com port (use setport)</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.IsOpen</Name>
    <Description>Pool the driver and return port status</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    <Action>
    <Name>SerialPort.Close</Name>
    <Description>Close opened port</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    <Action>
    <Name>SerialPort.SetSettings</Name>
    <Description>Set settings for por connection</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>Baud rate</Name>
    <Description>avalible 110 300 600 1200 2400 9600 14400 19200 28800 38400 56000 128000 256000</Description>
    <Type>number</Type>
    <Default>9600</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"9600"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    
    <Arg>
    <Name>Parity</Name>
    <Description>N: None E: Even M: Mark O: Odd S: Space</Description>
    <Type>string</Type>
    <Default>N</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"N"</Default>
    <DataType>string</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    
    <Arg>
    <Name>Databits</Name>
    <Description>avalible 4, 5, 6, 7, 8</Description>
    <Type>number</Type>
    <Default>8</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"8"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    
    <Arg>
    <Name>Stopbits</Name>
    <Description>avalible 1, 1.5, 2</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    
    <Arg>
    <Name>Flowcontrol Handshacking</Name>
    <Description>0: None 1: XON/XOFF 2: RTS/CTS 3: RTS XON/XOFF</Description>
    <Type>number</Type>
    <Default>0</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"0"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    
    <Action>
    <Name>SerialPort.SetPort</Name>
    <Description>Set working port before set settings and open</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>Port</Name>
    <Description>Port number</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.ListAvaliblePorts</Name>
    <Description>Return a table with avalible ports in the max, min range</Description>
    <ReturnValueType>table</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>PortStart</Name>
    <Description>starting number port</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>PortEnd</Name>
    <Description>end number port</Description>
    <Type>number</Type>
    <Default>16</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"16"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    <Action>
    <Name>SerialPort.SetRTS</Name>
    <Description>set rts line</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>RTS</Name>
    <Description>state of RTS line</Description>
    <Type>boolean</Type>
    <Default>true</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"true"</Default>
    <DataType>boolean</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.SetDTR</Name>
    <Description>set DTR line</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>DTR</Name>
    <Description>state of DTR line</Description>
    <Type>boolean</Type>
    <Default>true</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"true"</Default>
    <DataType>boolean</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.GetRTS</Name>
    <Description>get rts state</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.GetDTR</Name>
    <Description>get DTR state</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.Output</Name>
    <Description>Oiutput buffer to the serial port</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>Output</Name>
    <Description>String to output</Description>
    <Type>sting</Type>
    <Default></Default>
    <Required>1</Required>
    <EasyMode>
    <Default>""</Default>
    <DataType>string</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    <Arg>
    <Name>CRLF</Name>
    <Description>send  CR LF at the end of output</Description>
    <Type>boolean</Type>
    <Default>true</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"true"</Default>
    <DataType>boolean</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    <Action>
    <Name>SerialPort.Input</Name>
    <Description>Get Input buffer</Description>
    <ReturnValueType>string</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.BufferCount</Name>
    <Description>return the buffer stored</Description>
    <ReturnValueType>number</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    <Action>
    <Name>SerialPort.InputLen</Name>
    <Description>Len of Input</Description>
    <ReturnValueType>number</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>Stream</Name>
    <Description>Stream interface</Description>
    <Type>number</Type>
    <Default>1</Default>
    <Required>1</Required>
    <EasyMode>
    <Default>"1"</Default>
    <DataType>number</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    
    <Action>
    <Name>SerialPort.RegisterMscomm</Name>
    <Description>Register mscomm32.ocx</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>File</Name>
    <Description>Ocx control file</Description>
    <Type>file</Type>
    <Default></Default>
    <Required>1</Required>
    <EasyMode>
    <Default>""</Default>
    <DataType>file</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    <Action>
    <Name>SerialPort.RegisterNetComm</Name>
    <Description>Register netcomm.ocx</Description>
    <ReturnValueType>boolean</ReturnValueType>
    <Arguments>
    <Arg>
    <Name>File</Name>
    <Description>Ocx control file</Description>
    <Type>file</Type>
    <Default></Default>
    <Required>1</Required>
    <EasyMode>
    <Default>""</Default>
    <DataType>file</DataType>
    <Constraints>none</Constraints>
    </EasyMode>
    </Arg>
    </Arguments>
    </Action>
    
    
    
    </ActionTemplates>
    NEW VERSION! 1.1
    Attached Files

  9. #9
    Join Date
    Jun 2008
    Location
    AMSWaves
    Posts
    231
    Good work man this is very usefull, thanks

  10. #10
    Join Date
    Jul 2009
    Posts
    122

    Script Plugin intread LuaCom

    Hi amswaves, I tryed to use Script Action Plugin to create tha ax object but I cant get effect running on ams, but run correctly on vbs file...

    wath do you think?

  11. #11
    Join Date
    Jun 2008
    Location
    AMSWaves
    Posts
    231
    Quote Originally Posted by pabloko View Post
    Hi amswaves, I tryed to use Script Action Plugin to create tha ax object but I cant get effect running on ams, but run correctly on vbs file...

    wath do you think?
    you can post your example or that vbs file ?

  12. #12
    Join Date
    Jul 2009
    Posts
    122
    for example

    Code:
    Sub MyFunction()
        Set MSComm1=CreateObject("MSCOMMLib.MSComm")
        MSComm1.Settings = "9600,n,8,1"
        MSComm1.CommPort = 1
        MSComm1.InBufferCount = 0
        MSComm1.PortOpen = True
          If Err Then
             MsgBox "COM" & MSComm1.CommPort & ": not opened, Sorry!"
             Exit Sub
          End If
        MSComm1.Output="#1 P1500" & CHR(13)
        WScript.Sleep(1000)
        MSComm1.PortOpen = False
        Set MSComm1 = Nothing
    End Sub
    works with interpreter, but don't work in ams, and other example with autoit with similar problem

    Code:
    ; Set a COM Error handler -- only one can be active at a time (see helpfile)
    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    
    $sNumberToDial = "950346259"
    Dial($sNumberToDial)
    
    Exit
    
    Func Dial($pNum, $time2wait = 5000)
        
        dim $FromModem = ""
        $DialString = "ATDT" & $pNum & ";" & @CR
        
        $com = ObjCreate ("NETCommOCX.NETComm")
    
        With $com
            .CommPort = 4
            .PortOpen = True
            .Settings = "9600,N,8,1"
            .InBufferCount = 0
            .Output = $DialString
        EndWith
    
        $begin = TimerInit()
        While 1
            If $com.InBufferCount Then
                $FromModem = $FromModem & $com.InputData;* Check for "OK".
                If StringInStr($FromModem, "OK") Then;* Notify the user to pick up the phone.
                    MsgBox(0, "Phone", "Please pick up the phone and either press Enter or click OK")
                    ExitLoop
                EndIf
            EndIf
            If (TimerDiff($begin) > $time2wait) Then
                MsgBox(0, "Error", "No response from modem on COM" & $com.CommPort & " in " & $time2wait & " milliseconds")
                Exit
            EndIf
        WEnd
    
        $com.Output = "ATH" & @CR
        $com.PortOpen = False
        $com = 0
        
    EndFunc;==>Dial
    
    Func MyErrFunc()
    ; Set @ERROR to 1 and return control to the program following the trapped error
        SetError(1)
        MsgBox(0, "Error", "Error communicating with modem on COM" );& $com.CommPort)
        Exit
    EndFunc;==>MyErrFunc
    I try to become this code to ams, I finally decided by LuacOM, but Script plugin sounds good

    thanks

  13. #13
    Join Date
    Jun 2008
    Location
    AMSWaves
    Posts
    231
    Quote Originally Posted by pabloko View Post
    for example

    Code:
    Sub MyFunction()
        Set MSComm1=CreateObject("MSCOMMLib.MSComm")
        MSComm1.Settings = "9600,n,8,1"
        MSComm1.CommPort = 1
        MSComm1.InBufferCount = 0
        MSComm1.PortOpen = True
          If Err Then
             MsgBox "COM" & MSComm1.CommPort & ": not opened, Sorry!"
             Exit Sub
          End If
        MSComm1.Output="#1 P1500" & CHR(13)
        WScript.Sleep(1000)
        MSComm1.PortOpen = False
        Set MSComm1 = Nothing
    End Sub
    works with interpreter, but don't work in ams, and other example with autoit with similar problem

    Code:
    ; Set a COM Error handler -- only one can be active at a time (see helpfile)
    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    
    $sNumberToDial = "950346259"
    Dial($sNumberToDial)
    
    Exit
    
    Func Dial($pNum, $time2wait = 5000)
        
        dim $FromModem = ""
        $DialString = "ATDT" & $pNum & ";" & @CR
        
        $com = ObjCreate ("NETCommOCX.NETComm")
    
        With $com
            .CommPort = 4
            .PortOpen = True
            .Settings = "9600,N,8,1"
            .InBufferCount = 0
            .Output = $DialString
        EndWith
    
        $begin = TimerInit()
        While 1
            If $com.InBufferCount Then
                $FromModem = $FromModem & $com.InputData;* Check for "OK".
                If StringInStr($FromModem, "OK") Then;* Notify the user to pick up the phone.
                    MsgBox(0, "Phone", "Please pick up the phone and either press Enter or click OK")
                    ExitLoop
                EndIf
            EndIf
            If (TimerDiff($begin) > $time2wait) Then
                MsgBox(0, "Error", "No response from modem on COM" & $com.CommPort & " in " & $time2wait & " milliseconds")
                Exit
            EndIf
        WEnd
    
        $com.Output = "ATH" & @CR
        $com.PortOpen = False
        $com = 0
        
    EndFunc;==>Dial
    
    Func MyErrFunc()
    ; Set @ERROR to 1 and return control to the program following the trapped error
        SetError(1)
        MsgBox(0, "Error", "Error communicating with modem on COM" );& $com.CommPort)
        Exit
    EndFunc;==>MyErrFunc
    I try to become this code to ams, I finally decided by LuacOM, but Script plugin sounds good

    thanks
    your first code worked very good on script plugin, you just must remove one line (WScript.Sleep(1000)) because these codes not work on script plugin WScript.Sleep or WScript.Version or ...

    see this :
    Code:
    code =[[
    Sub MyFunction()
        Set MSComm1=CreateObject("MSCOMMLib.MSComm")
        MSComm1.Settings = "9600,n,8,1"
        MSComm1.CommPort = 1
        MSComm1.InBufferCount = 0
        MSComm1.PortOpen = True
          If Err Then
             MsgBox "COM" & MSComm1.CommPort & ": not opened, Sorry!"
             Exit Sub
          End If
        MSComm1.Output="#1 P1500" & CHR(13)
        MSComm1.PortOpen = False
        Set MSComm1 = Nothing
    End Sub
    
    MyFunction()
    ]]
    
    Script.SetLanguage(Script_VBScript);
    Script.AddCode(code, Script_InternalCode);
    but your second code not possible to run with script plugin or autoit plugin because Autoit plugin just have some ditinct method and cant run autoit codes.

  14. #14
    Join Date
    Jul 2009
    Posts
    122
    yay! WScript.Sleep(1000) is neccesary on several codes to wait a little, but i can change by system.sleep()...

    ...I prefer actual solution

    With Autoit i looked for AutoIt.ObjCreate but this doesn't exist

    this is was I try to say

  15. #15
    Join Date
    Jun 2008
    Location
    AMSWaves
    Posts
    231
    Quote Originally Posted by pabloko View Post
    yay! WScript.Sleep(1000) is neccesary on several codes to wait a little, but i can change by system.sleep()...

    ...I prefer actual solution

    With Autoit i looked for AutoIt.ObjCreate but this doesn't exist

    this is was I try to say
    pabloko autoit plugin cant run codes autoit depends on AutoitX and AutoIt.ObjCreate not supported in autoitx but im trying and hard working to add one method like AutoIt.RunCode or AutoIt.ExecCode for run autoit code from AMS App, in future maybe.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts