ph_comopensimple PowerHome formula function
Description
Opens the specified COM control. PowerHome provides the user with 5 COM controls that can be opened and characters received and written to. Same as ph_comopen with reduced parameters.
Syntax
ph_comopensimple ( comnum, comport, settings, id )
Argument |
Description |
comnum
|
The number of the COM control you are referencing. Valid values are 1 thru 5.
|
comport
|
The COM port you wish to open. Typically a number from 1 to 8 but can be higher.
|
settings
|
A string containing bps, parity, databits, and stopbits all separated by commas. To set the COM port to 9600 bps, parity NONE, 8 databits, and 1 stopbit, the settings string would be: "9600,N,8,1"
|
id
|
The ID of a macro to be called when characters are received.
|
Return value
Integer. Returns 0 if successful. Returns 1 if a comnum < 1 or > 5 is specified. Returns 2 if the specified COM is already open.
Usage
Allows the user to easily implement serial communications from within PowerHome. The COM control has an internal incoming buffer of 2048 characters. There are also two internal variables that track status of the incoming buffer. The buffercount variable keeps track of how many total characters are in the incoming buffer. The bufferptr variable points to the position of the last read character. Both these values start at zero. As characters arrive at the buffer, the buffercount variable is increased. If this value was zero and the ID parameter is not blank, the macro represented by the ID will be placed in the execution queue. As you read characters from the incoming buffer, the bufferptr variable is increased. When the bufferptr is equal to the buffercount (all characters have been read) both variables are reset to 0. If more characters are received, the macro will again be fired.