1

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

Mark Maurer
  • 101
  • 8

1 Answers1

1

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.

  • Thanks for that, I was able to pull the one line needed out of that to enable the uart, and confirmed that it was indeed on via the movesense ios app. – Mark Maurer Sep 19 '18 at 17:39
  • No problem, hope it helped. If you feel this was correct answer, maybe it would help others in future if you mark the answer as correct :) – Jari Tulilahti Sep 19 '18 at 18:23
  • done. as an aside, I was able to get wbcmd to see the port correctly if I just run it as "wbcmd --port /dev/cu.usbserial-AIO4RYMP". That gives me the help output, and then, at the bottom: Whiteboard - Tools/Wbcmd on MacOSX built at 2018-06-06T13:32:59Z Build 745 commit 31a83ee4ebc98d9a59e0f535de35d49f71209aad wb3.15.0-31a83ee4ebc98d9a59e0f535de35d49f71209aad However, trying to do any command, even just GET'ing /Info, and I'm back to 'Could not open connection...' a bug in wbcmd? – Mark Maurer Sep 19 '18 at 18:37
  • 1
    Leave out the first `/` from the path, as shells tend to expand them. Example: `wbcmd --port /dev/cu.usbserial-AIO4RYMP info` or `wbcmd --port /dev/cu.usbserial-AIO4RYMP system/energy/level` – Jari Tulilahti Sep 20 '18 at 18:04
  • uh, *completely* overlooked that. thanks for the reminder, all is working well now. – Mark Maurer Sep 21 '18 at 19:10