Skip to main content

Connecting to CS8000 devices

CS8000 devices enumerate as serial communication port when connected via USB to a computer. This chapter describes how to find and connect to CS8000 devices.

As you will see, the API hides many of the low-level details, related to serial port management, making it very easy to connect to CS8000 devices, and making the code portable between different operating systems (Windows, Linux, MacOS).

Opening a CS8000 device​

CS8000 API is sophisticated enough to handle both situation where there is a single CS8000 device connected to the computer, and situation where multiple CS8000 devices are connected to the same computer.

When there is a single CS8000 device connected to the computer, connecting to the device is very straightforward: simply create a new CS8000 object, providing the model name as parameter, and call the open() method. The API will automatically find the connected device and open it for communication.

When multiple CS8000 devices are connected to the same computer, each device must be identified using its unique serial number. In this case, when creating the CS8000 object, both the model name and the serial number must be provided as parameters. The open() method will then connect to the specified device.

Below are code examples for both situations.

import { CS8000 } from "@ikalogic/cs8000";
// Case 1: Single device connected
const sw = new CS8000("CS8216");
sw.open(); // Open the first available device
// Case 2: Multiple devices connected
const sw1 = new CS8000("CS8216");
const sw2 = new CS8000("CS8216");
sw1.open(308021600001); // Open the device with serial number 308021600001
sw2.open(308021600002); // Open the device with serial number 308021600002
Note

For the sake of simplicity, the following code examples will assume there is a single CS8000 device connected to the computer. If you are working with multiple devices, please refer to the above code examples.

Closing a CS8000 device​

When you are done using a CS8000 device, it is good practice to close the connection to the device using the close() method. This will free up the serial port and allow other applications to use it if needed.

Device status monitoring​

Once open, you can monitor the status of the device using the get_status() method. This method returns an object containing various status information about the device:

  • Firmware version
  • Hardware version
  • Sequence done flag : True if the sequence has completed, False otherwise
  • sequence address : Current address in the sequence memory
  • Loop counter : Number of loops remaining in the current sequence execution

Here is an example of how to use the get_status() method: import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

import { CS8000 } from "@ikalogic/cs8000";
const sw = new CS8000("CS8216");
sw.open(); // Open the first available device
const status = sw.get_status();
console.log("Firmware version:", status.version);
console.log("Hardware version:", status.hwRevision);
console.log("Sequence done:", status.sequenceDone);
console.log("Sequence address:", status.seqAddr);
console.log("Loop counter:", status.loopCounter);

This code will print the status information of the connected CS8000 device to the console.