How To Use The Generic Serial Driver on I/O Gateway
  • 27 Oct 2022
  • 4 Minutes to read
  • Contributors

How To Use The Generic Serial Driver on I/O Gateway


Article summary

How To Use The Generic Serial Driver on I/O Gateway

Learn how to allow the I/O Gateway to communicate with any serial device.

**On November 1, 2021, Tulip will no longer sell I/O Gateway devices. Edge IO and Edge MC Devices are still available. Learn More

Edge IO serial guide

Edge MC serial setup guide

This article will explain how to use the generic serial driver on your I/O Gateway to communicate with most serial devices. This article is generalizable to other Tulip Edge devices, such as the Edge MC and Edge IO.

This article assumes you have already completed the I/O gateway setup.

Note that this driver differs from the Serial Driver (Player Only) that is currently only available for the Windows Tulip Player.

What is the generic serial driver?

The generic serial driver allows the I/O Gateway to communicate with other devices using a common serial protocol. These devices can be things like:

  • Arduino
  • Raspberry Pi
  • Other Tulip Edge Devices
  • Micro controllers
  • Many other devices

Due to the versatility of this driver, it has a complex configuration. This configuration will need to match what your other device's configuration exactly.

This driver can support communicating with multiple devices at once.

Note: Tulip does not write custom code for devices that you connect to the generic serial driver.

Turning on the generic serial driver

Connect your computer to the I/O Gateway by logging into the local network that it creates.

Open the Device Portal. At the dashboards page, click on the "Configure Drivers" button on the left side of the page.

From the driver configuration page, click on the "Generic Serial" option.

By default, the "Generic Serial" option should already be green (enabled) and configured with some common settings.

Windows tends to use \r for its carriage returns.

The generic serial driver requires some configuration in order to proceed with turning on the driver.

Here are the options for each field:

Write suffix

  • Expected input: Any string - this is appended to any message the I/O Gateway will send to the device and is commonly a newline (\n) or a carriage return (\n\r)
  • Required: No

Path Matcher

  • Expected input: The system path to your device - this can be * to match with any unused serial device (this is useful for using usb-to-serial adapters)
  • Required: yes

Name

  • Expected input: The name of this device (this will be used to reference the device from your apps)
  • Required: yes

Delimiter

  • Expected input: Any string (this is used to split the message from your device into chunks to be sent to your Tulip account)
  • Required: yes

Baud

  • Expected input: The baud rate the device will use to communicate
  • Required: yes

Native DB9 port

If you plan to use the native DB9 port on the I/O Gateway you will need to use the path /dev/ttyO4 for your path matcher. That is is a capital O not a zero.

Building an app to work with your serial driver

Here's how to build an app to test your driver.

First, create a new app and add a button.

Add a trigger to that button to call out the generic serial device with the name you used to configure the driver.

Here are the fields you need in the "Then" statement:

  • "Run Device Function"
  • "Generic Serial Device"
  • "Send string to serial device"
  • At "this station"
  • Device to send to: "text" "RS232"
  • Message to send: "text" "testing generic serial"

Add a trigger to that app to record data into a variable when the generic serial driver emits data. Use an "If" statement to only store data if the correct device outputs data.

When

  • "Device" "Generic Serial Device" outputs at "this station"

If

  • "Device Output"
  • "name"
  • "="
  • "text" "RS232"

Then

  • "Data Manipulation"
  • "Store"
  • "Device output" "data"
  • location: "generic serial" (that is the name of a variable)

Add that variable to your app. It will be an object with "name" and "data" properties.

Test the app

Use a null modem and a USB to RS232 converter to test the app.

Connect the USB to your computer. Then connect the null modem adapter to the RS232 adapter and the I/O Gateway's DB9 port

Starting from:

If you are on Windows, use Putty to test connection. Get the Port number by using Device Manager.

Enter the COM port number in the "Speed" box and choose a "Connection Type" of "Serial"

The Putty terminal will only print messages to the I/O Gateway when you click the button in the app running.

Send the message 'Tulip' to through Putty by typing it and pressing enter.

How to test the generic serial driver on Linux or Mac using Node.js

This requires node.js and npm. Then, install the serialport package through npm.

const SerialPort = require('serialport')  
  
const Readline = require('@serialport/parser-readline')  
  
const port = new SerialPort('/dev/ttyUSB0', { baudRate: 19200 })  
  
   
  
const parser = new Readline()  
  
port.pipe(parser)  
  
   
  
parser.on('data', line => {  
  
  console.log(> ${line})  
  
});  
  
  
let test = false;  
  
  
setInterval(()=>{  
  
  if (test){  
  
    port.write('output\n');  
  
    test = false  
  
  }   
  
  else {  
  
    port.write('other output\n');  
  
    test = true  
  
  }  
  
},1000)

Was this article helpful?