Movesense:如何确定 mac os x 上的 wbcmd 端口

Movesense: how to determine wbcmd port on mac os x

我一直在研究,但似乎无法找到如何在编程夹具中确定 movesense 设备的正确端口,以便使用 wbcmd 工具查询设备。

我已经成功地使用夹具来刷新设备,所以这部分工作正常。我缺少的是如何确定 wbcmd 中的端口选项,以便成功与 mac os X(当前:High Sierra)上的设备通信。

我确实看到 /dev/cu.usbserial-AIO4RYMP 和 /dev/tty.usbserial-AIO4RYMP,但是使用其中一个 ose 作为 --port 选项只是 returns "No device connected"。

在这一点上,我不确定这是 wbcmd 问题还是设置问题,但同样,我可以在 High Sierra 上使用此设置成功刷新设备,没问题,事情 look 就像它们配置正确一样。

感谢您的帮助

我不会深入探讨 Mac 串行端口的细节,但简短的规则是 /dev/tty.* 用于传入(如 getty)而 /dev/cu.* 用于传出通信,所以你应该使用 /dev/cu.* 一个。

确保您在 App.cpp 中定义了 SERIAL_COMMUNICATION(true) 并且 请注意,启用串行通信会使 nRF52 的功耗增加几毫安。

编辑:我的观点是正确的,看起来 SERIAL_COMMUNICATION() -macro 在最新版本中已被弃用。最好的方法是在那里使用 WB API system/settings/uarton -path 和 PUT true 。此设置已保存,只需设置一次,下次重启后生效。

Settings API YAML

应用程序的小示例代码 (UartClient.cpp):

#include "movesense.h"
#include "UartClient.hpp"
#include "system_settings/resources.h"

const char* const UartClient::LAUNCHABLE_NAME = "UART";

UartClient::UartClient()
    : ResourceClient(WBDEBUG_NAME(__FUNCTION__), WB_EXEC_CTX_APPLICATION),
      LaunchableModule(LAUNCHABLE_NAME, WB_EXEC_CTX_APPLICATION)
{
}

UartClient::~UartClient()
{
}

bool UartClient::initModule()
{
    mModuleState = WB_RES::ModuleStateValues::INITIALIZED;
    return true;
}

void UartClient::deinitModule()
{
    mModuleState = WB_RES::ModuleStateValues::UNINITIALIZED;
}

bool UartClient::startModule()
{
    mModuleState = WB_RES::ModuleStateValues::STARTED;

    // Enable UART. Notice that the change takes effect on next reboot.
    ResourceClient::asyncPut(WB_RES::LOCAL::SYSTEM_SETTINGS_UARTON(), AsyncRequestOptions::Empty, true);
    return true;
}

void UartClient::stopModule()
{
    mModuleState = WB_RES::ModuleStateValues::STOPPED;
}

Header (UartClient.hpp):

#pragma once

#include <whiteboard/LaunchableModule.h>
#include <whiteboard/ResourceClient.h>

class UartClient FINAL : private whiteboard::ResourceClient,
                         public whiteboard::LaunchableModule

{
public:
    /** Name of this class. Used in StartupProvider list. */
    static const char* const LAUNCHABLE_NAME;
    UartClient();
    ~UartClient();

private:
    /** @see whiteboard::ILaunchableModule::initModule */
    virtual bool initModule() OVERRIDE;

    /** @see whiteboard::ILaunchableModule::deinitModule */
    virtual void deinitModule() OVERRIDE;

    /** @see whiteboard::ILaunchableModule::startModule */
    virtual bool startModule() OVERRIDE;

    /** @see whiteboard::ILaunchableModule::stopModule */
    virtual void stopModule() OVERRIDE;
};

或者您可以使用 iOS 示例应用程序,在 UI 中有一个启用 UART 的选项。该更改也会在下次重新启动时生效。