Input keyboard stdin

Hello.
How I can connect my keyboard form host RPI3 to container app?
I need to read some information from the user using a keyboard.
Thank you.

Hi. Is your container privileged?

Hello @floion. Thank you for responding. What you mean ‘privileged’? How can I do/set it?

Are you using a single container app or a multicontainer app?

Single container.
Need read keyboard input from rpi3.

If it’s a single container app, then by default it is privileged and it should have access to all device from the hostOS. Including the keyboard. You can use the webterminal in the resin dashboard to connect to your app container and then check “/dev/” to monitor if your device appears there when you plug in the keyboard

Yes, but stdin from nodejs don’t work.
Seems like container does not have it from hostos.
What I need to do, for open container nodejs app on rpi (stdin and stdout, not as background app).
Can you help me with example?
Thank you.

So did you test from the app container using the webterminal shell in the resin dashboard and it did not detect the inserted keyboard?
Before testing from your node app, it’s better to check if the keyboard is detected in the webterminal of your application container

@floion Yes, I see a new device on dmesg.
But question is - how to run container (single) with nodejs app on the main screen (not background) with input from a keyboard (map keyboard input to stdin).
Seems like now container run in the background. But as for me, need exec app in the main stream ( throw).

@shaunmulligan do we have any such example lying around?

No.
So I ask you provide simple nodejs or something else app with not background app and reading input from a keyboard.
it would be help many people

Hi. Our colleague @chrisys will try to create an example for you this week hopefully

Great!
@chrisys waiting for a sample from you :slight_smile:
And thanks.

Hey @Danylo, just to confirm I’m working on creating an example for you, I’ll post again when I have made some progress.

@Danylo so I’ve been working on this. Your original request is relatively easy to achieve; where you asked how to read keyboard input from the Raspberry Pi 3. I have created a Node example which does that here: https://github.com/balena-io-playground/node-keyboard-input

All you’ll have to do is change the vendor and product IDs to match your input device and you should see the output on a web page being served on port 80.

To actually use stdin from the console is proving to be a bit trickier. Could you explain your use case for us and we might be able to come up with some other options.

1 Like