Changes for page 01 Lua Functions

Last modified by Theodore Xu on 2023/10/26 10:51

From version 5.7
edited by Stone Wu
on 2022/07/12 09:20
Change comment: (Autosaved)
To version 5.9
edited by Stone Wu
on 2022/07/12 09:26
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -106,8 +106,6 @@
106 106  
107 107  (((
108 108  = **2 Address operation** =
109 -
110 -
111 111  )))
112 112  
113 113  |=16-bit data formal|=HLword|=32-bit data formal|=HLword|= 64-bit data formal|=HLword
... ... @@ -140,20 +140,17 @@
140 140  43218765
141 141  )))|10
142 142  
143 -* If HLword enters any other value, it will be treated as invalid.
141 + Table 2-1
144 144  
145 - Demo:  Reads a 32-bit floating-point number at position D0 of PLC
143 +(% class="box errormessage" %)
144 +(((
145 +**✎Note: **If HLword enters any other value, it will be treated as invalid.
146 +)))
146 146  
148 +== **addr_getshort(string addr[, number type, number hlword])** ==
147 147  
150 +**Function:** Read 16-bit signed decimal address
148 148  
149 -[[image:企业微信截图_20210506180640.png||height="301" width="600" class="img-thumbnail"]]
150 -
151 -== **2.1 addr_getshort(string addr[, number type, number hlword])** ==
152 -
153 -**Function:**
154 -
155 -Read 16-bit signed decimal address
156 -
157 157  **Parameters:**
158 158  
159 159  //addr//: address
... ... @@ -171,13 +171,11 @@
171 171  Failed: multi
172 172  
173 173  (((
174 -== **2.2 addr_setshort(string addr, number num[, number type, number hlword])** ==
169 +== **addr_setshort(string addr, number num[, number type, number hlword])** ==
175 175  )))
176 176  
177 -**Function:**
172 +**Function:** Write 16-bit signed decimal address
178 178  
179 -Write 16-bit signed decimal address
180 -
181 181  **Parameters:**
182 182  
183 183  //addr//: address
... ... @@ -195,13 +195,11 @@
195 195  Failed: multi
196 196  
197 197  (((
198 -== **2.3 addr_getword(string addr[, number type, number hlword])** ==
191 +== **addr_getword(string addr[, number type, number hlword])** ==
199 199  )))
200 200  
201 -**Function:**
194 +**Function:** Read 16-bit unsigned decimal address
202 202  
203 -Read 16-bit unsigned decimal address
204 -
205 205  **Parameters:**
206 206  
207 207  //addr//: address
... ... @@ -217,13 +217,11 @@
217 217  Failed: multi
218 218  
219 219  (((
220 -== **2.4 addr_setword(string addr, number num[, number type, number hlword])** ==
211 +== **addr_setword(string addr, number num[, number type, number hlword])** ==
221 221  )))
222 222  
223 -**Function:**
214 +**Function:**Write 16-bit unsigned decimal address
224 224  
225 -Write 16-bit unsigned decimal address
226 -
227 227  **Parameters:**
228 228  
229 229  //addr//: address
... ... @@ -241,13 +241,11 @@
241 241  Failed: multi
242 242  
243 243  (((
244 -== **2.5 addr_getint(string addr[, number type, number hlword])** ==
233 +== **addr_getint(string addr[, number type, number hlword])** ==
245 245  )))
246 246  
247 -**Function:**
236 +**Function:** Read 32-bit signed decimal address
248 248  
249 -Read 32-bit signed decimal address
250 -
251 251  **Parameters:**
252 252  
253 253  //addr//: address
... ... @@ -263,13 +263,11 @@
263 263  Failed: multi
264 264  
265 265  (((
266 -== **2.6 addr_setint(string addr, number num[, number type, number hlword])** ==
253 +== **addr_setint(string addr, number num[, number type, number hlword])** ==
267 267  )))
268 268  
269 -**Function:**
256 +**Function:** Write 32-bit signed decimal address
270 270  
271 -Write 32-bit signed decimal address
272 -
273 273  **Parameters:**
274 274  
275 275  //addr//: address
... ... @@ -287,13 +287,11 @@
287 287  Failed: multi
288 288  
289 289  (((
290 -== **2.7 addr_getdword(string addr[, number type, number hlword])** ==
275 +== **addr_getdword(string addr[, number type, number hlword])** ==
291 291  )))
292 292  
293 -**Function:**
278 +**Function:** Read 32-bit unsigned decimal address
294 294  
295 -Read 32-bit unsigned decimal address
296 -
297 297  **Parameters:**
298 298  
299 299  //addr//: address
... ... @@ -309,13 +309,11 @@
309 309  Failed: multi
310 310  
311 311  (((
312 -== **2.8 addr_setdword(string addr, number num[, number type, number hlword])** ==
295 +== **addr_setdword(string addr, number num[, number type, number hlword])** ==
313 313  )))
314 314  
315 -**Function:**
298 +**Function:** Write 32-bit unsigned decimal address
316 316  
317 -Write 32-bit unsigned decimal address
318 -
319 319  **Parameters:**
320 320  
321 321  //addr//: address
... ... @@ -333,13 +333,11 @@
333 333  Failed: multi
334 334  
335 335  (((
336 -== **2.9 addr_getbit(string addr[, number type])** ==
317 +== **addr_getbit(string addr[, number type])** ==
337 337  )))
338 338  
339 -**Function:**
320 +**Function:** Read a bit of the register address
340 340  
341 -Read a bit of the register address
342 -
343 343  **Parameters:**
344 344  
345 345  //addr//: address
... ... @@ -355,13 +355,11 @@
355 355  Failed: multi
356 356  
357 357  (((
358 -== **2.10 addr_setbit(string addr, number num[, number type])** ==
337 +== **addr_setbit(string addr, number num[, number type])** ==
359 359  )))
360 360  
361 -**Function:**
340 +**Function:** Write a bit of the register address
362 362  
363 -Write a bit of the register address
364 -
365 365  **Parameters:**
366 366  
367 367  //addr//: address
... ... @@ -379,13 +379,11 @@
379 379  Failed: multi
380 380  
381 381  (((
382 -== **2.11 addr_getfloat(string addr[, number type, number hlword])** ==
359 +== **addr_getfloat(string addr[, number type, number hlword])** ==
383 383  )))
384 384  
385 -**Function:**
362 +**Function:** Read 32-bit floating address
386 386  
387 -Read 32-bit floating address
388 -
389 389  **Parameters:**
390 390  
391 391  //addr//: address
... ... @@ -401,13 +401,11 @@
401 401  Failed: multi
402 402  
403 403  (((
404 -== **2.12 addr_setfloat(string addr, number num[, number type, number hlword])** ==
379 +== **addr_setfloat(string addr, number num[, number type, number hlword])** ==
405 405  )))
406 406  
407 -**Function:**
382 +**Function:** Write 32-bit floating address
408 408  
409 -Write 32-bit floating address
410 -
411 411  **Parameters:**
412 412  
413 413  //addr//: address
... ... @@ -425,13 +425,11 @@
425 425  Failed: multi
426 426  
427 427  (((
428 -== **2.13 addr_getdouble(string addr[, number type, number hlword])** ==
401 +== **addr_getdouble(string addr[, number type, number hlword])** ==
429 429  )))
430 430  
431 -**Function:**
404 +**Function:** Read 64-bit floating address
432 432  
433 -Read 64-bit floating address
434 -
435 435  **Parameters:**
436 436  
437 437  //addr//: address
... ... @@ -447,13 +447,11 @@
447 447  Failed: multi
448 448  
449 449  (((
450 -== **2.14 addr_setdouble(string addr, number num[, number type, number hlword])** ==
421 +== **addr_setdouble(string addr, number num[, number type, number hlword])** ==
451 451  )))
452 452  
453 -**Function:**
424 +**Function:** Write 64-bit floating address
454 454  
455 -Write 64-bit floating address
456 -
457 457  **Parameters:**
458 458  
459 459  addr: address
... ... @@ -471,13 +471,11 @@
471 471  Failed: multi
472 472  
473 473  (((
474 -== **2.15 addr_getstring(string addr, number length[, number type, number hlbyte])** ==
443 +== **addr_getstring(string addr, number length[, number type, number hlbyte])** ==
475 475  )))
476 476  
477 -**Function:**
446 +**Function:** Read the specified length string from address
478 478  
479 -Read the specified length string from address
480 -
481 481  **Parameters:**
482 482  
483 483  //addr//: address
... ... @@ -495,13 +495,11 @@
495 495  Failed: multi
496 496  
497 497  (((
498 -== **2.16 addr_setstring(string addr, string str[, number type, number hlbyte])** ==
465 +== **addr_setstring(string addr, string str[, number type, number hlbyte])** ==
499 499  )))
500 500  
501 -**Function:**
468 +**Function:** Write the specified length string to address
502 502  
503 -Write the specified length string to address
504 -
505 505  **Parameters:**
506 506  
507 507  //addr//: address
... ... @@ -519,13 +519,11 @@
519 519  Failed: multi
520 520  
521 521  (((
522 -== **2.17 addr_bmov(string dst, string src, number length)** ==
487 +== **addr_bmov(string dst, string src, number length)** ==
523 523  )))
524 524  
525 -**Function:**
490 +**Function:** Copy data from source address to destination address
526 526  
527 -Copy data from source address to destination address
528 -
529 529  **Parameters:**
530 530  
531 531  //dst//: destination address
... ... @@ -541,13 +541,11 @@
541 541  **Failed: multi**
542 542  
543 543  (((
544 -== **2.18 addr_fill(string addr, number num, number length)** ==
507 +== **addr_fill(string addr, number num, number length)** ==
545 545  )))
546 546  
547 -**Function:**
510 +**Function:** Write the same value to consecutive addresses
548 548  
549 -Write the same value to consecutive addresses
550 -
551 551  **Parameters:**
552 552  
553 553  //addr//: address
... ... @@ -563,13 +563,11 @@
563 563  Failed: multi
564 564  
565 565  (((
566 -== **2.19 addr_newnoaddr(string addr, number offset)** ==
527 +== **addr_newnoaddr(string addr, number offset)** ==
567 567  )))
568 568  
569 -**Function:**
530 +**Function:** Offset address value relative to //addr//
570 570  
571 -Offset address value relative to //addr//
572 -
573 573  **Parameters:**
574 574  
575 575  //addr//: address
... ... @@ -583,13 +583,11 @@
583 583  Failed: multi
584 584  
585 585  (((
586 -== **2.20 addr_newstataddr(string addr, number offset)** ==
545 +== **addr_newstataddr(string addr, number offset)** ==
587 587  )))
588 588  
589 -**Function:**
548 +**Function:** Offset station number relative to //addr //station number
590 590  
591 -Offset station number relative to //addr //station number
592 -
593 593  **Parameters:**
594 594  
595 595  //addr//: address
... ... @@ -602,12 +602,10 @@
602 602  
603 603  Failed: multi
604 604  
605 -== **2.21 addr_gethex64(string addr[, number type, number hlword])** ==
562 +== **addr_gethex64(string addr[, number type, number hlword])** ==
606 606  
607 -**Function:**
564 +**Function:** Read 64-bit hexadecimal numbers
608 608  
609 -Read 64-bit hexadecimal numbers
610 -
611 611  **Parameters:**
612 612  
613 613  //addr//: address
... ... @@ -622,12 +622,10 @@
622 622  
623 623  Failed: multi
624 624  
625 -== **2.22 addr_sethex64(string addr, number num[, number type, number hlword])** ==
580 +== **addr_sethex64(string addr, number num[, number type, number hlword])** ==
626 626  
627 -**Function:**
582 +**Function:** Write 64-bit hexadecimal addresses
628 628  
629 -Write 64-bit hexadecimal addresses
630 -
631 631  **Parameters:**
632 632  
633 633  //addr//: address
... ... @@ -648,11 +648,11 @@
648 648  
649 649  Operations on the serial port such as read, write, etc. must use ':' for full mode calls, ie operations on an open serial object.
650 650  
651 -**Serial port name and mode:**
604 +**Serial port name and mode**
652 652  
653 653  The serial port configured in the communication configuration window cannot be configured again using the script. RS232 and RS458 (or RS422) can be used simultaneously, but RS422 and RS485 are mutually exclusive.For example, when the communication port is configured with COM1-485, the script can only open COM1-232, but not COM1-485/422. Similarly, when the communication port is configured with COM2-485, the script can only open COM2-232, but not COM2-485.
654 654  
655 -Attempting to use a script to open a serial port in an unsupported mode will result in an error directly, as below
608 +Attempting to use a script to open a serial port in an unsupported mode will result in an error directly, as below.
656 656  
657 657  |(((
658 658  local setup = {
... ... @@ -674,13 +674,11 @@
674 674  1. When the data bit is 8, the maximum value of data transmission is 255 (0xFF), which supports the transmission of any character.
675 675  
676 676  (((
677 -== **3.1 serial.open(table setup)** ==
630 +== **serial.open(table setup)** ==
678 678  )))
679 679  
680 -**Function:**
633 +**Function:** Enable one serial port
681 681  
682 -Enable one serial port
683 -
684 684  **Parameters:**
685 685  
686 686  //Setup// is a Lua table; it needs to contain the following fields
... ... @@ -714,17 +714,13 @@
714 714  Failed: multi
715 715  
716 716  (((
717 -== **3.2 serial.close(serial obj)** ==
668 +== **serial.close(serial obj)** ==
718 718  )))
719 719  
720 -**Function:**
671 +**Function:** Disable the serial port
721 721  
722 -Disable the serial port
673 +**Parameters: **//Obj //is the object returned by serial.open
723 723  
724 -**Parameters:**
725 -
726 -//Obj //is the object returned by serial.open
727 -
728 728  **Return:**
729 729  
730 730  Succeed: true
... ... @@ -732,13 +732,11 @@
732 732  Failed: multi
733 733  
734 734  (((
735 -== **3.3 serial:read(number bytes[, number timeout])** ==
682 +== **serial:read(number bytes[, number timeout])** ==
736 736  )))
737 737  
738 -**Function:**
685 +**Function:** Read the specified byte length serial port data
739 739  
740 -Read the specified byte length serial port data
741 -
742 742  **Parameters:**
743 743  
744 744  //bytes//: number of bytes
... ... @@ -752,15 +752,13 @@
752 752  Failed: multi
753 753  
754 754  (((
755 -== **3.4 serial:write(string data)** ==
700 +== **serial:write(string data)** ==
756 756  )))
757 757  
758 -**Function:**
703 +**Function:** Write the specified byte length to serial port data
759 759  
760 -Write the specified byte length to serial port data
705 +**Parameters: **
761 761  
762 -**Parameters:**
763 -
764 764  //data//: serial port data
765 765  
766 766  **Return:**
... ... @@ -770,13 +770,11 @@
770 770  Failed: multi
771 771  
772 772  (((
773 -== **3.5 serial:flush([number flag])** ==
716 +== **serial:flush([number flag])** ==
774 774  )))
775 775  
776 -**Function:**
719 +**Function:** Clear the serial port buffer
777 777  
778 -Clear the serial port buffer
779 -
780 780  **Parameters:**
781 781  
782 782  //[flag=2]// clear option: 0: read, 1: write, 2: read-write
... ... @@ -788,17 +788,13 @@
788 788  Failed: multi
789 789  
790 790  (((
791 -== **3.6 serial:close()** ==
732 +== **serial:close()** ==
792 792  )))
793 793  
794 -**Function:**
735 +**Function:** Close the serial port object
795 795  
796 -Close the serial port object
737 +**Parameters:** None
797 797  
798 -**Parameters:**
799 -
800 -None
801 -
802 802  **Return:**
803 803  
804 804  Succeed: true