MDB Products
Released
Getting Started
MDB Developers' Playground - Code Samples and Examples
Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Hello Qiba
Copy Markdown
Open in ChatGPT
Open in Claude
This program is the equivalent to the very famous Hello World in programming, but applied to our API. This program gets the firmware version from Qiba's devices and prints it to the screen.
Python3
Python
import serialser = serial.Serial() #Create Serial Objectser.baudrate = 115200 #Set the appropriate BaudRateser.timeout = 50 #The maximum timeout that the program waits for a reply. If 0 is used, the pot is blocked until readline returnsser.port = '/dev/ttyACM0' # Specify the device file descriptorser.open() #Open the serial connectionser.write(b'V\n') #Write the version command "V\n" encoded in Binarys = ser.readline() # Read the responseprint('Version:' + s.decode('ascii')) # Print it on the terminal, note the decoding to ascii.To execute the program, just copy the code above to a file "helloqiba.py" and run it like shown below.
Bash
sudo python3 helloqiba.pyC
It is necessary to install the System.IO.Ports package to use this example:
[https://www.nuget.org/packages/System.IO.Ports/](https://www.nuget.org/packages/System.IO.Ports/)**
**
C#
x
using System.IO.Ports;public class Program { static SerialPort _serialPort; public static void Main() { // Create a new SerialPort object with default settings. _serialPort = new SerialPort(); StringComparer stringComparer = StringComparer.Ordinal; // Change the serial port properties: _serialPort.PortName = "COM5"; //Change port device _serialPort.BaudRate = 115200; _serialPort.Parity = Parity.None; _serialPort.DataBits = 8; _serialPort.StopBits = StopBits.One; _serialPort.Handshake = Handshake.None; // Set the read/write timeouts _serialPort.ReadTimeout = 500; _serialPort.WriteTimeout = 500; _serialPort.Open(); WriteSerial("V"); ReadSerial(); } //Write a string to serial port public static void WriteSerial(string command) { _serialPort.WriteLine(command); } //Read a reply from serial port. Returns empty string if nothing is read within timeout public static string ReadSerial() { string message; try { message = _serialPort.ReadLine(); Console.WriteLine(message); }catch (TimeoutException) { return ""; } return message; }}Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
Last updated on
Next to read:
Data Sniffer(C) 2024 Qibixx AG - contact us with any questions: info@qibixx.com
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message