Einzelnen Beitrag anzeigen
Alt 11.10.2012, 00:12   #102
leecher
Moderator
IOGETSTR

E r g e b n i s / R e s u l t

This routine retrieves a string from the serial port and places it into the typeahead buffer. This can be used to retrieve any size of string.

B e s c h r e i b u n g / D e s c r i p t i o n

S y n t a x

Code:
CALL("IOGETSTR", PORT, BAUD, PARITY, DATABITS, STOPBITS, TERM, LEN, TIMEOUT)
P a r a m e t e r

Code:
      PORT is the comport to use. Either 1 or 2.

      BAUD is the baud rate. Use appropriate value 0-7
         Baud    value
         110      0
         150      1
         300      2
         600      3
         1200      4
         2400      5
         4800      6
         9600      7

      PARITY is the parity to be used. Use appropriate value 0-4
         Baud    value
         NONE      0
         ODD       1
         EVEN      2
         MARK      3
         IGNORE    4

      DATABITS is the number of data bits to be used. Use appropriate
      value 0-3
         DATA BITS 5     0     
         DATA BITS 6     1     
         DATA BITS 7     2
         DATA BITS 8     3

      STOPBITS is the number of stop bits to be used. Use appropriate
      value 0-1
         STOP BITS 1     0
         STOP BITS 2     1

      TERM is an integer of the ascii value of the terminating character. 
      If the string is terminated by a carriage return, TERM=13.

      LEN is an integer of how many characters to read.  Only use LEN if
      the strings being sent are always a fixed length (the same size).
      Max number of chars is <= 80 or whatever your application needs.

      Use either LEN or TERM but not both. If the string size is variable
      and a terminating character is sent, set LEN to 255 and TERM to the
      number of the ascii terminating character.

      TIMEOUT is the number in tenths of a second to wait for the incoming
      string before timing out.  If a timeout error occurs the function
      returns.
R e t u r n s

B e i s p i e l / E x a m p l e

This will read a string from comport 1 until a CR(13) is read, with a baud=9600, no parity, 8 databits and 1 stop bit, timeout will be 20 seconds.
Code:
CALL("IOGETSTR", 1, 7, 0, 3, 0, 13, 255, 200)
This will read a string from comport 2 until a 25 characters are read, with a baud=1200, no parity, 8 databits and 1 stop bit, timeout will be 10 seconds.
Code:
CALL("IOGETSTR", 2, 4, 0, 3, 0, 0, 25, 100)
Angehängte Dateien
Dateityp: oac IOGETSTR.OAC‎ (15.5 KB, 6x aufgerufen)
Dateityp: zip IOGETSTR.ZIP‎ (10.7 KB, 2x aufgerufen)
leecher ist offline   Mit Zitat antworten