11<!-- Badges -->
2- [ Build Win32 DLL ] : https://img.shields.io/github/actions/workflow/status/TypeScriptPlayground/Serial/build_windows.yml?label=Build%20Win32%20DLL&labelColor=343b42&logo=github&logoColor=959DA5 ' Win32 Build '
3- [ Build Linux SO ] : https://img.shields.io/github/actions/workflow/status/TypeScriptPlayground/Serial/build_linux.yml?label=Build%20Linux%20SO&labelColor=343b42&logo=github&logoColor=959DA5 ' Linux Build '
2+ [ Build binaries ] : https://img.shields.io/github/actions/workflow/status/TypeScriptPlayground/Serial/build_windows.yml?label=Build%20binaries&labelColor=343b42&logo=github&logoColor=959DA5 ' Build binaries '
43[ Release Downloads ] : https://img.shields.io/github/downloads/TypeScriptPlayground/Serial/total?label=Downloads%20&labelColor=343b42&logo=docusign&logoColor=959DA5 ' Total Release Downloads '
54
65# Serial
7- [ ![ Build Win32 DLL]] ( https://github.com/TypeScriptPlayground/Serial/actions/workflows/build_windows.yml )
8- [ ![ Build Linux SO]] ( https://github.com/TypeScriptPlayground/Serial/actions/workflows/build_linux.yml )
6+ [ ![ Build binaries]] ( https://github.com/TypeScriptPlayground/Serial/actions/workflows/build.yml )
97[ ![ Release Downloads]] ( https://github.com/TypeScriptPlayground/Serial/releases )
108
119<a href =" https://deno.land " ><img align =" right " src =" https://deno.land/logo.svg " height =" 150px " alt =" the deno mascot dinosaur standing in the rain " ></a >
@@ -33,10 +31,10 @@ This library provides an interface for the communication with serial devices and
3331- Works on different operating systems (check [ compatibility] ( #compatibility ) for mor info).
3432
3533## Compatibility
36- | OS | Tested version | Current state |
37- | ---------| ------------------| ---------------|
38- | Windows | Windows 10 (x64) | implemented |
39- | Linux | - | in progress |
34+ | OS | Tested version | Current state |
35+ | ---------| ------------------------- | ---------------|
36+ | Windows | Windows 10 (x64) | implemented |
37+ | Linux | Ubuntu Server 22.04 LTS | implemented |
4038
4139## Possible/Known issues
4240- What happens if you open multiple connections from the same instance.
@@ -45,6 +43,10 @@ This library provides an interface for the communication with serial devices and
4543- Linux write currently not working
4644
4745## Examples - How to use
46+ To use this library you need the following flags to run it:
47+ - ` --unstable `
48+ - ` --allow-ffi `
49+
4850### Ports
4951Get a list with all serial ports and their info that are currently available on your system.
5052
@@ -77,17 +79,17 @@ Send data to a serial device. For exampe to an [Arduino](https://www.arduino.cc/
7779
7880`main.ts`
7981```typescript
80- import { Serial } from "./mod.ts";
82+ import { Serial, baudrate } from "./mod.ts";
8183
8284// create new instance of a serial object
8385const serial = new Serial();
8486
8587// open the connection
86- serial.open();
88+ serial.open('COM1', baudrate.B9600 );
8789
8890// encode the message to a Uint8Array
89- const textToSend = 'Hello from TypeScript!'
90- const encodedTextToSend = new TextEncoder().encode(textToSend)
91+ const textToSend = 'Hello from TypeScript!';
92+ const encodedTextToSend = new TextEncoder().encode(textToSend);
9193
9294// send the message
9395serial.send(encodedTextToSend, encodedTextToSend.length);
@@ -113,13 +115,13 @@ void loop() {
113115
114116` main.ts `
115117``` typescript
116- import { Serial } from " ./mod.ts" ;
118+ import { Serial , baudrate } from " ./mod.ts" ;
117119
118120// create new instance of a serial object
119121const serial = new Serial ();
120122
121123// open the connection
122- serial .open ();
124+ serial .open (' COM1 ' , baudrate . B9600 );
123125
124126// create a new buffer to store incoming bytes,
125127// in this example we want to read a maximum of 100 bytes
0 commit comments