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.