Examples
Discussion
The serial object works only with ports and devices supported by the standard serial driver. It does not work with USB ports and devices, unless a USB to Serial adaptor is connected.
Arguments
port [symbol]
Specifies the serial port to be used by the serial object. If alphabetic shortcuts (a-z) are used, specifies the first logical serial port in the computer, and - are used to specify additional ports.
portname [symbol]
If actual portnames are used, the symbol is the name given by the Operating System to your port. The serial object can be used to create a list of available portnames and alphabetic shortcuts. If the port chosen is currently in use or unavailable when the serial object is instantiated, an error message will be displayed and the object will not function. If no port is specified, the default port is .
to therate [int]
An optional argument may be used after the port name or alphabetic shortcut to specify the baud rate of the serial port (the default rate is 4800 baud). Any value is allowable (although not all ports can be set to all baud rates). Some common rates are 300, 600, 1200, 1800, 2400, 3600, 7200, 9600, 19200, 38400, 57600 and 115200.
data [int]
After the baud rate, the next arguments specifies the number of data bits for the serial port (the default is 8 data bits). Other possible values are 5, 6 and 7.
stop [int]
The next argument specifies the number of stop bits for the serial port. The default is 1. Other possible values are 1.5 (Windows only) and 2.
parity [int or symbol]
The next argument specifies the parity for the serial port (the default is no parity, specified by
or ).Other possible values are , (odd), , and (odd).Attributes
autoopen [int]
Toggles automatically opening the serial port.
baud [int]
Sets the port's baud rate.
Possible values:
'300'
'1200'
'2400'
'4800'
'9600'
'14400'
'19200'
'28800'
'38400'
'57600'
'115200'
bufsize [int]
Sets the input buffer size used by the serial object.
chunk [int]
Sets the data chunk size (data list length) for output.
databits [int]
Sets the number of data bits (acceptable values are 5, 6, 7, or 8).
Possible values:
'5'
'6'
'7'
'8'
defer [int] (default: 1)
Defer Output
drain [int]
(Mac only) Toggles drain enable. When enabled, communication waits until all data has been transmitted to the terminal when writing. The default value is 0 (disabled).
dtr [int]
Enables or disables the DTR (data terminal ready) function of the serial port used by the serial object.
parity [int]
Sets the parity for the port. The options are:
0: no parity
1: odd
2: even
Possible values:
0 = 'no'
1 = 'odd'
2 = 'even'
poll [float] (default: 0.)
Poll Enable/Interval
serport [int]
Used by the object Inspector only. Users should use the
Possible values:
0 = 'Bluetooth-Incoming-Port'
1 = 'Bluetooth-Modem'
stopbits [int]
Sets the number of stop bits used when communicating with the serial port.
Possible values:
'1'
'2'
xonxoff [int]
Enables Xon/Xoff serial flow control.
Common Box Attributes
annotation [symbol]
Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.
background [int] (default: 0)
Adds or removes the object from the patcher's background layer.
adds the object to the background layer, removes it. Objects in the background layer are shown behind all objects in the default foreground layer.color [4 floats]
Sets the color for the object box outline.
fontface [int]
Sets the type style used by the object. The options are:
plain
bold
italic
bold italic
Possible values:
0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'
fontname [symbol]
Sets the object's font.
fontsize [float]
Sets the object's font size (in points).
Possible values:
'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'
hidden [int] (default: 0)
Toggles whether an object is hidden when the patcher is locked.
hint [symbol]
Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.
ignoreclick [int] (default: 0)
Toggles whether an object ignores mouse clicks in a locked patcher.
patching_rect [4 floats] (default: 0. 0. 100. 0.)
Sets the position and size of the object in the patcher window.
position [2 floats]
Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.
presentation [int] (default: 0)
Sets whether an object belongs to the patcher's presentation.
presentation_rect [4 floats] (default: 0. 0. 0. 0.)
Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.
rect [4 floats]
Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).
size [2 floats]
Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.
textcolor [float]
Sets the color for the object's text in RGBA format.
textjustification [int]
Text Justification
Possible values:
0 = 'left'
1 = 'center'
2 = 'right'
varname [symbol]
Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.
Messages
bang
int
Arguments
float
Arguments
list
Arguments
break
close
getport
port
Arguments
open
refresh
reset
Output
(serial output)
When a number or list is received in its inlet, serial sends the data out the specified serial port at the current baud rate.
int
When serial receives a message and characters have been received in the serial port, the received characters are sent as numbers in the order they were received.
list
When serial receives a message, characters have been received in the serial port, and chunking is enabled, the received characters are sent as a list in the order the characters were received. The length of the list is determined by the argument to the message (see the message listing for for more information).
Out right outlet: Reports error and status messages.
See Also
Name | Description |
---|---|
Using Max with Hardware | Using Max with Hardware |
match | Watch for a message match, then output the message |
spell | Convert input to UTF-8 (Unicode) codes |
vdp | Control a videodisk player through a serial port |
Max Comm Tutorial 2: Serial Communication | Max Comm Tutorial 2: Serial Communication |