Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add COM port API & List COM ports for adalight
- Loading branch information
1 parent
36954be
commit 16dd429
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
import serial.tools.list_ports | ||
from aiohttp import web | ||
|
||
from ledfx.api import RestEndpoint | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class InfoEndpoint(RestEndpoint): | ||
|
||
ENDPOINT_PATH = "/api/comports" | ||
|
||
async def get(self) -> web.Response: | ||
|
||
ports = serial.tools.list_ports.comports() | ||
|
||
available_ports = [] | ||
|
||
for p in ports: | ||
available_ports.append(p.device) | ||
|
||
return web.json_response(data=available_ports, status=200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters