0

我正在尝试按照分步说明将树莓派零 2 设置为使用 AWS Greengrass 的物联网设备。我在 YouTube 上发现了一个非常好的说明 - 使用带有 Raspberry Pi 的 AWS Greengrass IoT v2 构建 DIY 火星探测器 | ACG 项目 ( https://www.youtube.com/watch?v=Ity2Z03Lp1k )。

我能够按照所有说明进行操作,最后尝试测试与 MQTT 测试客户端的连接。但是,在我ping它之后,它没有显示任何内容。当我重新启动树莓派时,MQTT 控制台显示以下消息,表明 SnapPicture.py 已损坏。

$aws/things/RealPi2/shadow/name/AWSManagedGreengrassV2Deployment/get

{
  "shadowName": "AWSManagedGreengrassV2Deployment",
  "thingName": "RealPi2"
}
$aws/things/RealPi2/shadow/name/AWSManagedGreengrassV2Deployment/get/accepted

{
  "state": {
    "desired": {
      "fleetConfig": "{\"deploymentId\":\XXXXXXXXXXXXXXXXXX\",\"schemaDate\":\"2021-05-17\",\"deploymentName\":\"Deployment for RealPi2\",\"configurationArn\":\"arn:aws:greengrass:us-west-2:953054857915:configuration:thing/RealPi2:9\",\"creationTimestamp\":1639762626973,\"components\":{\"aws.greengrass.Cli\":{\"version\":\"2.5.2\"},\"snapPicture\":{\"version\":\"1.0.0\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}},\"aws.greengrass.Nucleus\":{\"version\":\"2.5.2\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}}},\"failureHandlingPolicy\":\"DO_NOTHING\",\"requiredCapabilities\":[],\"componentUpdatePolicy\":{\"timeout\":60,\"action\":\"NOTIFY_COMPONENTS\"},\"configurationValidationPolicy\":{\"timeout\":60}}",
      "desiredStatus": "COMPLETED"
    },
    "reported": {
      "ggcVersion": "2.5.2",
      "fleetConfigurationArnForStatus": "arn:aws:greengrass:us-west-2:953054857915:configuration:thing/RealPi2:9",
      "statusDetails": {
        "detailedStatus": "SUCCESSFUL",
        "failureCause": "Service snapPicture in broken state after deployment"
      },
      "status": "SUCCEEDED"
    },
    "delta": {
      "fleetConfig": "{\"deploymentId\":\"9d0fa215-d1ca-40b1-b361-73820b7a669b\",\"schemaDate\":\"2021-05-17\",\"deploymentName\":\"Deployment for RealPi2\",\"configurationArn\":\"arn:aws:greengrass:us-west-2:953054857915:configuration:thing/RealPi2:9\",\"creationTimestamp\":1639762626973,\"components\":{\"aws.greengrass.Cli\":{\"version\":\"2.5.2\"},\"snapPicture\":{\"version\":\"1.0.0\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}},\"aws.greengrass.Nucleus\":{\"version\":\"2.5.2\",\"configurationUpdate\":{\"merge\":{\"jvmOptions\":\"-Xmx64m -XX:+UseSerialGC -XX:TieredStopAtLevel=1\"}},\"runWith\":{}}},\"failureHandlingPolicy\":\"DO_NOTHING\",\"requiredCapabilities\":[],\"componentUpdatePolicy\":{\"timeout\":60,\"action\":\"NOTIFY_COMPONENTS\"},\"configurationValidationPolicy\":{\"timeout\":60}}",
      "desiredStatus": "COMPLETED"
    }
  },
  "metadata": {
    "desired": {
      "fleetConfig": {
        "timestamp": 1639762627
      },
      "desiredStatus": {
        "timestamp": 1639762627
      }
    },
    "reported": {
      "ggcVersion": {
        "timestamp": 1639762672
      },
      "fleetConfigurationArnForStatus": {
        "timestamp": 1639762672
      },
      "statusDetails": {
        "detailedStatus": {
          "timestamp": 1639762672
        },
        "failureCause": {
          "timestamp": 1639422348
        }
      },
      "status": {
        "timestamp": 1639762672
      }
    }
  },
  "version": 28,
  "timestamp": 1639922924
}

我独立运行了带有参数的 snapPicture.py,结果如下。

Traceback (most recent call last):
  File "snapPicture.py", line 29, in <module>
    ipc_client = awsiot.greengrasscoreipc.connect()
  File "/home/pi/.local/lib/python3.7/site-packages/awsiot/greengrasscoreipc/__init__.py", line 45, in connect
    ipc_socket = os.environ["AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT"]
  File "/usr/lib/python3.7/os.py", line 678, in __getitem__
    raise KeyError(key) from None
KeyError: 'AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT'

我的怀疑是它ipc_client = awsiot.greengrasscoreipc.connect()不能正常工作。

任何建议将不胜感激。

脱模剂

4

0 回答 0