Macro stop on serial input

Taichi  Jul 02, 2019

How do you get the macro to stop when serial data is received?  Can a specific hex sequence be used for triggering the stop?

Thank you.


Noritake VFD  Jul 03, 2019

Hello Taichi,

You can stop a program macro when serial data is received with the following program macro code:

‘/////////////////////////////////////////////

‘Global Variable

RecBff = &h00   ‘ Receiving Buffer

Sub Start()

                Cursor 0,0

                Cls          ‘Clear Screen

lp:

                ‘Receive Serial Data

                If RecCount <> 0 Then

                                GoTo Coda

                End If

                GoTo lp

Coda:

End Sub

‘//////////////////////////////////////////////

Essentially, this code checks the value of the receiving buffer (RecCount). If the receiving buffer is not zero (RecCount <> 0), then go to the end of the program macro.

Yes, a predefined data sequence can be specified to stop a program macro to stop.

The following code illustrates a program macro exiting upon receiving 0x40.

‘/////////////////////////////////////////////

‘Global Variable

RecBff = &h00   ‘ Receiving Buffer

Sub Start()

                Cursor 0,0

                Cls          ‘Clear Screen

lp:

                ‘Receive Serial Data

                If RecCount <> 0 Then

                                RecBff = Com ‘Read one byte of receiving buffer

                                If RecBff = &h40 Then

                                                GoTo Coda

                                End If

                                Print RecBff

                End If

                GoTo lp

Coda:

End Sub

‘//////////////////////////////////////////////