Announcement

Collapse
No announcement yet.

serial port plugin for AMS 8.x

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • serial port plugin for AMS 8.x

    Hi
    I need serial port plugin for AMS 8.x
    this link plugin for AMS 7.x :
    http://www.indigorose.com/forums/thr...510#post143510
    How to use plugin for AMS 8.x ?
    Last Version 1.4.0.0

  • #2
    I'm Need it, too.
    Please release it for AMS 8
    Thanks

    Comment


    • #3
      This serial port plugin source code
      Please compile to AMS8 plugin
      I very need to this

      Source Code : SerialPort.lua
      Code:
      SerialPort = {Stored = {}};
      SerialPort.Version = 1.3;
      function SerialPort.Init(portNumber)
         local axComPort={}
         netms=0
         axComPort[portNumber]=luacom.CreateObject("NETCommOCX.NETComm")
         if (axComPort[portNumber]==nil) then
             axComPort[portNumber]=luacom.CreateObject("MSCommLib.MSComm")
             if (axComPort[portNumber]==nil) then
                 --return false
                 return nil;
             else
                 netms=1
                 axComPort[portNumber].CommPort=portNumber
                 return axComPort[portNumber];
                 --return true
             end
         else
             axComPort[portNumber].CommPort=portNumber
             return axComPort[portNumber];
             --return true
         end
      end
      -------------------------------------------------------
      function SerialPort.TerminateAll(handle)
         handle=nil
      end
      -------------------------------------------------------
      function SerialPort.Terminate(handle)
         handle.PortOpen=false
         handle=nil
      end
      -------------------------------------------------------
      function SerialPort.Open(handle, port)
         --local oldPort = handle.CommPort
         handle.CommPort=port;
         handle.PortOpen=true;
         return handle.PortOpen;
         --handle.CommPort = oldPort
      end
      -------------------------------------------------------
      function SerialPort.IsOpen(handle)
         return handle.PortOpen
      end
      -------------------------------------------------------
      function SerialPort.Close(handle, port)
         --local oldPort = handle.CommPort
         handle.CommPort=port
         handle.PortOpen=false
         --handle.CommPort = oldPort
         return handle.PortOpen
      end
      -------------------------------------------------------
      function SerialPort.SetSettings(handle,nBauds,nParity,nDatabit,nStopbit,nFlowcontrol)
         handle.Settings=nBauds..nParity..nDatabit..nStopbit..nFlowcontrol
      end
      -------------------------------------------------------
      function SerialPort.ListAvaliblePorts(handle,nStart,nEnd)
         local ports={}
         local oldPort = handle.CommPort
         for x = nStart, nEnd do
            if x ~= 4 and x~= 5 then
               handle.CommPort=x
                if (handle.PortOpen==true) then
                   --port is already open
                else
                   handle.PortOpen=true
                   if (handle.PortOpen==true) then
                        Table.Insert(ports, Table.Count(ports)+1, x);
                        handle.PortOpen=false
                     end
                end
            end
         end
         if Table.Count(ports)>1 then
            return ports
         else
            return nil;
         end
      end
      
      function SerialPort.SetP(handle, port)
         handle.CommPort=port
      end
      function SerialPort.CleanBufferCount(handle)
         handle.InBufferCount = 0;
      end
      -------------------------------------------------------
      function SerialPort.SetRTS(handle, nRTS)
         handle.RTSEnable=nRTS
      end
      -------------------------------------------------------
      function SerialPort.SetDTR(handle, nDTR)
         handle.DTREnable=nDTR
      end
      -------------------------------------------------------
      function SerialPort.GetRTS(handle)
         return handle.RTSEnable
      end
      -------------------------------------------------------
      function SerialPort.GetDTR(handle)
         return handle.DTREnable
      end
      -------------------------------------------------------
      function SerialPort.Output(handle,sOutput,nBreak)
         if (nBreak==true) then
            sOutput=sOutput..String.Char(13)
         end
         handle.Output=sOutput
      end
      -------------------------------------------------------
      function SerialPort.Input(handle)
         if (netms==1) then
            return handle.Input
         else
            return handle.InputData
         end
      end
      -------------------------------------------------------
      function SerialPort.BufferCount(handle)
         return handle.InBufferCount
      end
      -------------------------------------------------------
      function SerialPort.InputLen(handle)
         return handle.InputLen
      end
      -------------------------------------------------------
      function SerialPort.RegisterMscomm()
         bOK = Registry.DoesKeyExist(HKEY_CLASSES_ROOT,"CLSID\\{648A5600-2C6E-101B-82B6-000000000014}\\InprocServer32");
         if (bOK) then
            return false
         else
            PSDK.ExportArchive(3000, "AutoPlay\\Docs\\mscomm.ocx");
            System.RegisterActiveX("AutoPlay\\Docs\\mscomm.ocx");
            return true
         end
      end
      -------------------------------------------------------
      function SerialPort.RegisterNetComm()
         bOK = Registry.DoesKeyExist(HKEY_CLASSES_ROOT,"CLSID\\{53867031-6B4D-4F7D-B089-5DFEC731F5FA}\\InprocServer32");
         if (bOK) then
            return false
         else
            PSDK.ExportArchive(3001, "AutoPlay\\Docs\\netcomm.ocx");
            System.RegisterActiveX("AutoPlay\\Docs\\netcomm.ocx");
            return true
         end
      end
      Source Code : SerialPort.xml
      Code:
      <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>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.Terminate</Name>
      <Description>close opened ports and free Com Object</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.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>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.IsOpen</Name>
      <Description>Pool the driver and return port status</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.Close</Name>
      <Description>Close opened port</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.SetSettings</Name>
      <Description>Set settings for por connection</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>
      <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.ListAvaliblePorts</Name>
      <Description>Return a table with avalible ports in the max, min range</Description>
      <ReturnValueType>table</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>
      <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>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>
      <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>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>
      <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>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.GetDTR</Name>
      <Description>get DTR state</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.Output</Name>
      <Description>Oiutput buffer to the serial port</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>
      <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>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.BufferCount</Name>
      <Description>return the buffer stored</Description>
      <ReturnValueType>number</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.InputLen</Name>
      <Description>Len of Input</Description>
      <ReturnValueType>number</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.RegisterMscomm</Name>
      <Description>Register mscomm32.ocx</Description>
      <ReturnValueType>boolean</ReturnValueType>
      </Action>
       
       
      <Action>
      <Name>SerialPort.RegisterNetComm</Name>
      <Description>Register netcomm.ocx</Description>
      <ReturnValueType>boolean</ReturnValueType>
      </Action>
       
       
       
      </ActionTemplates>

      Comment

      Working...
      X