ON_RECEIVE

ON_RECEIVE N,L

EXECUTES THE PROGRAM FROM LABEL L WHEN A CHARACTER IS RECEIVED THROUGH THE SERIAL LINK NUMBER N

  • Type: Command
  • Parameters: 2
  • Group: Events

ACTION

The command ON_RECEIVE N,L assigns a label (which must be defined in the program) from which the program will run every time a character is received through the serial link number N.

A system object SERIAL having the number N must have been created.

SYNTAX: ON_RECEIVE N,L

  • N = serial link number (integer or real). N must be greater than 0 and less than or equal to 10.
  • L = Label.

USE

  • The command ON_RECEIVE is used to associate an event (character received) happening to a serial link, to a program location (defined by the label L).
  • When the event occurs, the program named by the label is executed.

ERROR

  • If number N is not a correct expression.
  • If number N is greater than 10.
  • If number N is less than 0.
  • If system object number N does not exist.
  • If system object number N is not of the type : SERIAL.
  • If the label L does not exist.
  • If L is not a correct label name.

EXAMPLE

label received

rem create object for serial link

serial 1

rem configuration of serial link

serial_port 1,3

serial_baudrate 1,1200

serial_databits 1,8

serial_stopbits 1,1

serial_parity 1,0

serial_open 1

rem if data received

on_receive 2,received

rem transmission

serial_write 1,"A"

end

received:

print serial_read$(1)

return

SEE ALSO

SERIAL

SERIAL_PORT

SERIAL_BAUDRATE

SERIAL_STOPBITS

SERIAL_DATABITS

SERIAL_PARITY

SERIAL_OPEN

SERIAL_CLOSE

SERIAL_WRITE

SERIAL_PORT_EXISTS()

SERIAL_READ$()