
Hello, how can I achieve to connect an USB port (Serial device) to Appwrite, to use it on functions?

Hi there, thank you for your question, allow me a moment to look into it, can you once confirm which SDK are you using?

I will be using Python SDK. Thanks to you

Can you elaborate a bit on how you plan on using Appwrite with a USB device and/or share about your usecase so we can help you better?

Sure.
I'm going to capture some data from gas sensors using a RS485-USB adapter. Right now I'm testing in windows, but the machine that I'm going to use is gonna have Linux.
import minimalmodbus
import serial
def create_sensors(usb_port, num_sensors):
sensor_array = []
for i in range(num_sensors):
sensor = minimalmodbus.Instrument(usb_port, (i + 1))
sensor.serial.baudrate = 9600
sensor.serial.bytesize = 8
sensor.serial.parity = serial.PARITY_NONE
sensor.serial.stopbits = 1
sensor.serial.timeout = 0.05
sensor.mode = minimalmodbus.MODE_RTU
sensor.clear_buffers_before_each_transaction = True
sensor_array.append(sensor)
return sensor_array
This is a part of the code. An those are the libraries

I mean, I can use basic linux configuration to execute scripts directly from OS, but, I want to use Appwrite for everything, so I can figure out all its potential.

I hope I can do this

Unfortunately, this is currently not possible since the functions runtimes do not have access to the host's USB ports.
However never say never and we would love to discuss this over a Github issue, can you please open one issue as feature request here: https://github.com/appwrite/appwrite/issues
The workaround would be to use any esp-8266 enabled device like a node-mcu and transmit the sensor data to the appwrite database. This data can then be accessed inside the function. Please refer to this:
https://appwrite.io/docs/server/databases?sdk=python-default#databasesCreateDocument to sensor data

Oh, that is really sad. ESP is a nice idea, but I have to get the interface first.
Can functions runtimes access to some folder inside host's?

Function runtimes run completely isolated from the host. This is to prevent any kind of malicious code of one user, affecting other users using the same appwrite server and also to prevent malicious code from taking down the entire server.

Can I do something to change that? Any workaround?

Hey, talking of workarounds, I think CreateDocument would be the best but let me just confirm with my team if there is a better way

i think you need to create another docker container that has access enabled for serial and inside the function try to put the function container with the other serial enabled container in one instance btw search for multi-stage builds i believe it can be all done through the same function, let me know if you get there
Recommended threads
- Direct Upgrade from Appwrite v1.5.11 to ...
I'm on Appwrite v1.5.11. Can I upgrade directly to v1.6.2?
- error code:524 for functions running lon...
We are having this issue, no longer the function runtime or code, if it goes longer than 1 minute, there's no logs at all, just this error: **error code: 524**
- PKCE, Etsy, OIDC, External OAuth provide...
first, thanks for creating and maintaining this software. I'm almost glad i couldn't convince my (wise and wonderful) senior devs to try pocketbase on productio...
