aws / aws-iot-device-sdk-arduino-yun

SDK for connecting to AWS IoT from an Arduino Yún.
Apache License 2.0
163 stars 77 forks source link

Grove.ino sketch - [ERR] command: setup code: -1 #63

Closed silverage01 closed 6 years ago

silverage01 commented 6 years ago

Getting an error when trying to run GroveWithAWSIot.ino on my board. Here are the errors I am seeing in Serial Monitor on COM9:

AWS IoT SDK Version(dev) 2.2.0-
root@Seeed:/# /bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
Linux
/bin/ash: cd: can't ce/
python: can't open file 'run.py': [Errno 2] No such file or dir
[ERR] command: setup code: -1 

I am following the instructions here: http://wiki.seeed.cc/Seeeduino_Cloud_and_Grove_IoT_Starter_Kit_Powered_by_AWS/

Here are my aws_iot_config.h contents:

/*
 * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

#ifndef config_usr_h
#define config_usr_h

// Copy and paste your configuration into this file
//===============================================================

#define AWS_IOT_MQTT_HOST "a3pujgfo1m12iq.iot.us-west-2.amazonaws.com"     
// your endpoint
#define AWS_IOT_MQTT_PORT 8883
// your port
#define AWS_IOT_CLIENT_ID      "temperature"
// your client ID
#define AWS_IOT_MY_THING_NAME "temperature"
// your thing name
#define AWS_IOT_ROOT_CA_FILENAME "root-CA.crt"
// your root-CA filename
#define AWS_IOT_CERTIFICATE_FILENAME "7a984e56d2-certificate.pem.crt"
// your certificate filename
#define AWS_IOT_PRIVATE_KEY_FILENAME "7a984e56d2-private.pem.key"
// your private key filename

//===============================================================

// SDK config, DO NOT modify it
#define AWS_IOT_PATH_PREFIX "../certs/"
#define AWS_IOT_ROOT_CA_PATH AWS_IOT_PATH_PREFIX AWS_IOT_ROOT_CA_FILENAME           // use this in config call
#define AWS_IOT_CERTIFICATE_PATH AWS_IOT_PATH_PREFIX AWS_IOT_CERTIFICATE_FILENAME   // use this in config call
#define AWS_IOT_PRIVATE_KEY_PATH AWS_IOT_PATH_PREFIX AWS_IOT_PRIVATE_KEY_FILENAME   // use this in config call

#endif
liuszeng commented 6 years ago

Hi @stephenalbright ,

Thank you very much for using AWS IoT Arduino Yun SDK.

From the logs, it seems like the SDK is not able to cd into /root/AWS-IoT-Python-Runtime/runtime/ and therefore run.py cannot be found and start the Python runtime on AR9331.

Can you ssh into the board and do a ls -R ~ and attach the output? I would like to see the folder structure on AR9331 after the installation.

Thanks, Liusu

silverage01 commented 6 years ago

File attached with the directory structure.

Directory Output.docx

silverage01 commented 6 years ago

 

Hi Liusu,

 

The directory structure is attached to a comment here:

 

https://github.com/aws/aws-iot-device-sdk-arduino-yun/issues/63

 

Thanks,

 

Steve

Sent: Tuesday, January 23, 2018 at 1:14 PM From: "Liusu Zeng" notifications@github.com To: aws/aws-iot-device-sdk-arduino-yun aws-iot-device-sdk-arduino-yun@noreply.github.com Mention mention@noreply.github.com Subject: Re: [aws/aws-iot-device-sdk-arduino-yun] GroveWithAWSIot.ino sketch - [ERR] command: setup code: -1 (#63)

Hi,

Thank you very much for using AWS IoT Arduino Yun SDK.

From the logs, it seems like the SDK is not able to cd into /root/AWS-IoT-Python-Runtime/runtime/ and therefore run.py cannot be found and start the Python runtime on AR9331.

Can you ssh into the board and do a ls -R ~ and attach the output? I would like to see the folder structure on AR9331 after the installation.

Thanks, Liusu

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

 

liuszeng commented 6 years ago

Hi @stephenalbright ,

Thank you very much for providing the information.

It seems like you have installed the Python runtime part of the SDK library to directory /. Can you try reinstall the library to directory /root instead? If you followed the installation instructions correctly before, for now you can simply copy paste /AWS-IoT-Python-Runtime into /root.

cd /
cp -r ./AWS-IoT-Python-Runtime /root/

After that, let's do another list view of directory /root/AWS-IoT-Python-Runtime/ and see if we have everything in the right place:

cd /root/
ls ./AWS-IoT-Python-Runtime

Thanks, Liusu

silverage01 commented 6 years ago

Ok, I copied the directory as you instructed. Here is what it looks like now (not sure why the text is being struck through in this text editor):

root@Seeed:~# ls AWS-IoT-Python-Runtime root@Seeed:~# cd /root/ root@Seeed:~# ls ./AWS-IoT-Python-Runtime certs lib log runtime root@Seeed:~# cd .. root@Seeed:/# ls AWS-IoT-Python-Runtime output.txt sys bin overlay tmp dev proc usr etc rom var lib root www mnt sbin root@Seeed:/#

When I run the sketch now, there are some errors in the serial monitor, but the shadow is being updated in AWS IoT. Here is the output from the serial monitor:

AWS IoT SDK Version(dev) 2.2.0-

root@Seeed:~/AWS-IoT-Python-Runtime/runtime# 1 /bin/ash: /root: Permission denied /bin/ash: 1: not found /bin/ash: /root: Permission denied /bin/ash: 1: not found /bin/ash: /root: Permission denied /bin/ash: 1: not found /bin/ash: /root: Permission denied Linux /

I T [LOG] command: setup completed.

G T [LOG] command: config completed.

C T [LOG] command: connect completed.

SI T [LOG] command: shadow init completed.

S_RD T [LOG] command: register thing shadow delta function completed. Current temperature is -273.15

silverage01 commented 6 years ago

Ticket updated here:

 

https://github.com/aws/aws-iot-device-sdk-arduino-yun/issues/63

 

Sent: Tuesday, January 23, 2018 at 11:13 PM From: "Liusu Zeng" notifications@github.com To: aws/aws-iot-device-sdk-arduino-yun aws-iot-device-sdk-arduino-yun@noreply.github.com Mention mention@noreply.github.com Subject: Re: [aws/aws-iot-device-sdk-arduino-yun] GroveWithAWSIot.ino sketch - [ERR] command: setup code: -1 (#63)

Hi,

Thank you very much for providing the information.

It seems like you have installed the Python runtime part of the SDK library to directory /. Can you try reinstall the library to directory /root/ instead? If you followed the installation instructions correctly before, for now you can simply copy paste /AWS-IoT-Python-Runtime into /root.

cd / cp -r ./AWS-IoT-Python-Runtime /root/

After that, let's do another list view of directory /root/AWS-IoT-Python-Runtime/ and see if we have everything in the right place:

cd /root/ ls ./AWS-IoT-Python-Runtime

Thanks, Liusu

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

 

liuszeng commented 6 years ago

Hi @stephenalbright ,

Those lines of "not found" and "permission denied" are expected. They are the result of the testing commands to skip over the welcoming prompt on AR9331 and ensure that the serial1 communication is actually working for passing commands from your sketch to the Python runtime. More details can be found in the following line of code: https://github.com/aws/aws-iot-device-sdk-arduino-yun/blob/master/AWS-IoT-Arduino-Yun-Library/aws_iot_mqtt.cpp#L862

You should now get your sketch and SDK working correctly.

Thanks, Liusu

silverage01 commented 6 years ago

If I let the sketch run long enough, here is the kind of output I see in the serial monitor. Is this normal behavior as well?

SU T [LOG] command: shadow update completed.

Z T

Y 2 0 JSON-288

Y F: No messages. Current temperature is 347.68

SU3F: Invalid JSON payload. [ERR] command: shadow update code: -31

Z T

Y 1 0 JSON-291

Y F: No messages. Current temperature is -273.15

liuszeng commented 6 years ago

Hi @stephenalbright ,

The error code -31 (or "SU3F" you see) means that there is an value error when invoking the shadow update. Mostly like there is a JSON parsing error in processing the outgoing request payload. This could be caused in difference scenarios, e.g., invalid input JSON in the sketch or the input JSON is corrupted when communicating from ATmega 32u4 to AR9331. For more details, you can take a look at the following line in the Python runtime code: https://github.com/aws/aws-iot-device-sdk-arduino-yun/blob/master/AWS-IoT-Python-Runtime/lib/command/commandShadowUpdate.py#L63

You can always perform retries to ensure that your shadow update actually reaches to the cloud.

Thanks, Liusu

liuszeng commented 6 years ago

Closing the issue due to inactivity.