Skip to content

jasniec/BlazorSerial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlazorSerial

BlazorSerial is a library that wraps the serial API in chrome based browsers check it here

Installation

Use the package manager to install BlazorSerial.

PM> Install-Package BlazorSerial

Or add nuget instead

Then, in your index file (wwwroot/index.html) add a line at the bottom of the body

<script src="_content/BlazorSerial/blazorSerial.js"></script>

And register dependency in Program.cs file

builder.Services.AddBlazorSerial();

Usage

To write text to the serial port, you have to ask user to choose a port, if successfully chosen, you have to connect and then send some text.

@inject ISerialPort Serial

// ...

@code{
private async Task WriteHelloWorld()
{
    if (await Serial.RequestPort() == BlazorSerial.Enums.RequestPortResponseEnum.Ok
     && await Serial.Open(115200) == BlazorSerial.Enums.ConnectResponseEnum.Ok)
    {
        await Serial.Write("Hello World!");
    }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published