- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
Hi,
Can you try to develop your code as a Greengrass component and not as a Lambda?
https://docs.aws.amazon.com/greengrass/v2/developerguide/create-components.html
As you correctly identified, if running as a Lambda, you have to figure out how to mount the devices into the container lambda is running within.
If you do want to run a Lambda in V2 inside a container for some reason, please look at the docs here: https://docs.aws.amazon.com/greengrass/v2/developerguide/import-lambda-function-console.html#import-lambda-console-run-isolated
This shows how to mount volumes and devices into the container so your lambda can access them.
Hi,
Thank you very much for replying!!
Maybe I have not explained properly what I have so far in my previous post, but never mind, I will try as many times as it were neccesary!
Right now, I have developed two components as a first approach (speaking of sensor stuff only):
1- The first one generates two random values of temperature and humidity, since readings from DHT22 sensor makes the component crash due to what I told before, and that is what I am trying to fix.
2- The second one is subscribed to those values in order to switch on or switch off the led if a predefined threshold is exceeded. It happens the same as exposed in the other component.
*Note -> Fortunately, the first link you shared before does the same as the workshop.
The lambda will be developed after this has been completed in order to send alarms, and maybe, to control the led instead of the component, but that will be the next step for sure.
Perhaps this is a wrong way and it has to be done differently, but in any case, the hardware access will have to be accesible in one of them.
I hope this clarifies the issue, feel free to ask me for whatever you need (I mean, logs, files developed and so on).
Looking forward to hearing from you.
Kind regards.
Daniel.
Hi there!
I would like to report that I have advances, and they are that both components are working with direct hardware iterations on the Raspberry Pi (in this case, GPIOs for both the sensor and the led diode).
I was able to see in the logs for the components the following sentence:
2021-06-07T09:43:10.488Z -WARN- (Copier) com.example.Subscriber: stderr. RuntimeError: No access to /dev/mem. Try running as root!. {scriptName=services.com.example.Subscriber.lifecycle.Run, serviceName=com.example.Subscriber, currentState=RUNNING}
That actually gave me a great clue, so I did a little reseach, finding that it was that I had no permissions in /dev/mem and in /dev/gpio* folders for the AWS Greengrass group in the core device, so I included them by using the commands shown below:
sudo usermod -aG kmem ggc_user
sudo usermod -aG gpio ggc_user
I hope this help people that might have the same problem. Now I will try the lambda functionalities, moving the led part here, so I will let you know if I have any more issues.
Thank you very much for your support.
Kind regards.
Daniel.
Edited by: dpergarc on Jun 8, 2021 1:49 AM
Contenuto pertinente
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata 3 anni fa