Method: SerialPort#set_modem_params

Defined in:
ext/native/serialport.c

#set_modem_params(baud, data_bits, stop_bits, parity) ⇒ Hash #set_modem_params(hash) ⇒ Hash

Configure the serial port. You can pass a hash or multiple values as separate arguments. Invalid or unsupported values will raise an ArgumentError.

When using a hash the following keys are recognized:

“baud”

Integer from 50 to 256000, depending on platform

“data_bits”

Integer from 5 to 8 (4 is allowed on Windows too)

“stop_bits”

Integer, only allowed values are 1 or 2 (1.5 is not supported)

“parity”

One of the constants NONE, EVEN or ODD (Windows allows also MARK and SPACE)

When using separate arguments, they are interpreted as:

(baud, data_bits = 8, stop_bits = 1, parity = (previous_databits == 8 ? NONE : EVEN))

A baudrate of nil will keep the old value. The default parity depends on the number of databits configured before this function call.

Overloads:

  • #set_modem_params(baud, data_bits, stop_bits, parity) ⇒ Hash

    Parameters:

    • baud (Integer)

      the baud rate

    • data_bits (Integer)

      the number of data bits

    • stop_bits (Integer)

      the number of stop bits

    • parity (Integer)

      the type of parity checking

  • #set_modem_params(hash) ⇒ Hash

    Parameters:

    • opts (Hash)

      the options to configure port

Returns:

  • (Hash)

    the original paramters

Raises:

  • (ArgumentError)

    if values are invalide or unsupported



62
63
# File 'ext/native/serialport.c', line 62

static VALUE sp_set_modem_params(argc, argv, self)
int argc;