Changes for page 01 Lua Functions
Last modified by Theodore Xu on 2023/10/26 10:51
From version 9.2
edited by Stone Wu
on 2022/07/25 11:32
on 2022/07/25 11:32
Change comment:
Update document after refactoring.
To version 20.1
edited by Theodore Xu
on 2023/08/25 09:49
on 2023/08/25 09:49
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,1 +1,1 @@ 1 -V-BOX.V-Net.04 Lua Script.WebHome 1 +V-BOX.V-Net.Manual.04 Lua Script.WebHome - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. Stone1 +XWiki.AiXia - Content
-
... ... @@ -1507,8 +1507,19 @@ 1507 1507 ** addr_getstring("@W_HSW191",17) 1508 1508 * Obtaining ICCID (read only) 1509 1509 ** addr_getstring("@W_HSW225",15) 1510 +* ((( 1511 +TSAP settings of Siemens LOGO PLC* 1510 1510 1511 1511 ((( 1514 +addr_setword("@W_0#HSW1200",8192) means set the Local TSAP as 20.00 1515 +))) 1516 + 1517 +* ((( 1518 +addr_setword("@W_0#HSW1201",4096) means set the Remote TSAP as 10.00 1519 +))) 1520 +))) 1521 + 1522 +((( 1512 1512 == **Power-down storage area (HAW/HAX)** == 1513 1513 1514 1514 The system storage area (HAW) is used for the system power-down hold registers: ... ... @@ -1861,186 +1861,8 @@ 1861 1861 1862 1862 Failed: nil 1863 1863 1864 -= **11 M ySQL databaseoperation** =1875 += **11 Message summary algorithm** = 1865 1865 1866 -== **luaMySql.init(string sourcename, string username, string password, string host, number port, string character)** == 1867 - 1868 -**Function:** Configure database connection parameters 1869 - 1870 -**Parameter:** 1871 - 1872 -sourcename: the name of database 1873 - 1874 -username: the username of the connection 1875 - 1876 -password: the password of the connection 1877 - 1878 -host: the host name of the connection 1879 - 1880 -port: the host port of the connection 1881 - 1882 -character: the character set of the connection 1883 - 1884 -**Return:** 1885 - 1886 -Succeed: string 1887 - 1888 -Failed: multi 1889 - 1890 -== **luaMySql.exec(string statement)** == 1891 - 1892 -**Function:** Execute the given SQL statement without returning the result set (add, delete, change) 1893 - 1894 -**Parameter:** 1895 - 1896 -statement: the given SQL statement 1897 - 1898 -**Return:** 1899 - 1900 -Succeed: status: returns the number of rows affected by SQL statement execution. 1901 - 1902 -Failed: nil, errorString 1903 - 1904 -== **luaMySql.execWithResult(string statement)** == 1905 - 1906 -**Function:** Execute the given SQL statement returning the result set (check) 1907 - 1908 -**Parameter:** 1909 - 1910 -statement: the given SQL statement 1911 - 1912 -**Return:** 1913 - 1914 -Succeed: table: returns the result set 1915 - 1916 -Failed: nil, errorString 1917 - 1918 -**For example:** 1919 - 1920 -{{code language="LUA"}} 1921 -mysql = require"mysqlclient" 1922 - 1923 -function DataInitRight() 1924 - 1925 -local dbName = "db_lua1" 1926 - 1927 -local user = "root" 1928 - 1929 -local pwd = "123456" 1930 - 1931 -local host = "192.168.56.186" 1932 - 1933 -local port = 3306 1934 -local character = "UTF8" 1935 - 1936 -mysql.init(dbName, user, pwd, host, port, character) 1937 - 1938 -end 1939 - 1940 -function ExecFunc() 1941 - 1942 -status, errorString = mysql.exec("delete from tb_lua1 where mykey = 1943 - 1944 -10;") 1945 - 1946 -if nil == status then 1947 - 1948 -print("ExecFunc() error:", errorString) 1949 - 1950 -return -1 1951 - 1952 -else 1953 - 1954 -print("the number of rows affected by the command:", status) 1955 - 1956 -end 1957 - 1958 -return 0 1959 - 1960 -end 1961 - 1962 -function ExecWithResultFunc() 1963 - 1964 -status, errorString = mysql.execWithResult("select * from tb_lua1;") 1965 - 1966 -if nil == status then 1967 - 1968 -print("ExecWithResultFunc() error:", errorString) 1969 - 1970 -return -1 1971 - 1972 -else 1973 - 1974 -print("ExecWithResultFunc() 1975 - 1976 -success 1977 - 1978 -: status 1979 - 1980 -type 1981 - 1982 -= 1983 - 1984 -", 1985 - 1986 -type(status)) 1987 - 1988 -print("ExecWithResultFunc() success : status len = ", #status) 1989 - 1990 -local num = #status 1991 - 1992 -local i = 1 1993 - 1994 -if num > 0 then 1995 - 1996 -for i = 1, num, 1 do 1997 - 1998 -local var = string.format("select result[%d] :mykey = %d, 1999 - 2000 -value = %s", i, status[i].mykey, status[i].value) 2001 - 2002 -print(var) 2003 - 2004 -end 2005 - 2006 -end 2007 - 2008 -print("---------------") 2009 - 2010 -end 2011 - 2012 -return 0 2013 -end 2014 - 2015 -function luaMysql_apiTest.main() 2016 - 2017 -print("script running ...") 2018 - 2019 -DataInitRight() 2020 - 2021 ---use exec demo 2022 - 2023 -if ExecFunc() < 0 then 2024 - 2025 -return 2026 - 2027 -end 2028 - 2029 ---use execWithResult demo 2030 - 2031 -if ExecWithResultFunc() < 0 then 2032 - 2033 -return 2034 - 2035 -end 2036 - 2037 -print("script running success") 2038 - 2039 -end 2040 -{{/code}} 2041 - 2042 -= **12 Message summary algorithm** = 2043 - 2044 2044 == **hmac(string hash_func, string key, string message)** == 2045 2045 2046 2046 **Function:** HMAC calculate