Movesense: how to determine wbcmd port on mac os x

280 Views Asked by At

I've been digging around, but can't seem to find how to determine the proper port for a movesense device in the programming jig in order to use the wbcmd tool to query the device.

I've successfully used the jig to reflash devices, so that part is working. What I'm missing is how to determine the port option in wbcmd in order to successfully talk to the device on mac os X (currently: High Sierra).

I do see /dev/cu.usbserial-AIO4RYMP and /dev/tty.usbserial-AIO4RYMP, but using either of those as the --port option just returns "No device connected".

At this point, I am unsure if it's a wbcmd problem or a setup problem, but again, I can successfully flash a device with this setup on High Sierra no problem, and things look like they're configured correctly.

Thanks for any help

1

There are 1 best solutions below

5
On BEST ANSWER

I'm not going deep into details of Mac serial ports but short rule is that /dev/tty.* is for incoming (like getty) and /dev/cu.* is for outgoing communication, so you should use the /dev/cu.* one.

Make sure you have defined SERIAL_COMMUNICATION(true) in your App.cpp and also note that enabling serial communication increases power usage of nRF52 by few milliamps.

EDIT: I stand corrected, looks like SERIAL_COMMUNICATION() -macro is deprecated in latest builds. Best way then is to use WB API system/settings/uarton -path and PUT true there. This setting is stored and needs to be done only once, and it takes effect on next reboot.

See Settings API YAML

Small sample code for application (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;
};

Alternatively you can use the iOS sample application, there is an option to enable UART in UI. That change also takes effect on next reboot.