diff --git a/examples/apps/cli/main.c b/examples/apps/cli/main.c index 3113d943b..b02aec7e3 100644 --- a/examples/apps/cli/main.c +++ b/examples/apps/cli/main.c @@ -27,7 +27,7 @@ */ #include -#include +#include #include void otSignalTaskletPending(void) @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { PlatformInit(argc, argv); otInit(); - otCliSerialInit(); + otCliUartInit(); while (1) { diff --git a/examples/platforms/cc2538/Makefile.am b/examples/platforms/cc2538/Makefile.am index 7c35e0c86..ed451a94e 100644 --- a/examples/platforms/cc2538/Makefile.am +++ b/examples/platforms/cc2538/Makefile.am @@ -41,7 +41,7 @@ libopenthread_cc2538_a_SOURCES = \ platform.c \ radio.c \ random.c \ - serial.c \ + uart.c \ startup-gcc.c \ $(NULL) diff --git a/examples/platforms/cc2538/platform-cc2538.h b/examples/platforms/cc2538/platform-cc2538.h index fb9b55e07..5afa972b8 100644 --- a/examples/platforms/cc2538/platform-cc2538.h +++ b/examples/platforms/cc2538/platform-cc2538.h @@ -70,9 +70,9 @@ void cc2538RadioProcess(void); void cc2538RandomInit(void); /** - * This function performs radio driver processing. + * This function performs UART driver processing. * */ -void cc2538SerialProcess(void); +void cc2538UartProcess(void); #endif // PLATFORM_CC2538_H_ diff --git a/examples/platforms/cc2538/platform.c b/examples/platforms/cc2538/platform.c index e17b46e45..d555dee0b 100644 --- a/examples/platforms/cc2538/platform.c +++ b/examples/platforms/cc2538/platform.c @@ -32,7 +32,7 @@ * This file includes the platform-specific initializers. */ -#include +#include #include "platform-cc2538.h" void PlatformInit(int argc, char *argv[]) @@ -40,14 +40,14 @@ void PlatformInit(int argc, char *argv[]) cc2538AlarmInit(); cc2538RadioInit(); cc2538RandomInit(); - otPlatSerialEnable(); + otPlatUartEnable(); } void PlatformProcessDrivers(void) { // should sleep and wait for interrupts here - cc2538SerialProcess(); + cc2538UartProcess(); cc2538RadioProcess(); cc2538AlarmProcess(); } diff --git a/examples/platforms/cc2538/serial.c b/examples/platforms/cc2538/uart.c similarity index 92% rename from examples/platforms/cc2538/serial.c rename to examples/platforms/cc2538/uart.c index 38934a231..9c5c48a13 100644 --- a/examples/platforms/cc2538/serial.c +++ b/examples/platforms/cc2538/uart.c @@ -28,7 +28,7 @@ /** * @file - * This file implements the OpenThread platform abstraction for serial communication. + * This file implements the OpenThread platform abstraction for UART communication. * */ @@ -36,7 +36,7 @@ #include #include -#include +#include #include "platform-cc2538.h" enum @@ -58,7 +58,7 @@ static uint8_t sReceiveBuffer[kReceiveBufferSize]; static uint16_t sReceiveHead = 0; static uint16_t sReceiveLength = 0; -ThreadError otPlatSerialEnable(void) +ThreadError otPlatUartEnable(void) { uint32_t div; @@ -99,12 +99,12 @@ ThreadError otPlatSerialEnable(void) return kThreadError_None; } -ThreadError otPlatSerialDisable(void) +ThreadError otPlatUartDisable(void) { return kThreadError_None; } -ThreadError otPlatSerialSend(const uint8_t *aBuf, uint16_t aBufLength) +ThreadError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength) { ThreadError error = kThreadError_None; @@ -127,14 +127,14 @@ void processReceive(void) if (sReceiveLength >= remaining) { - otPlatSerialReceived(sReceiveBuffer + sReceiveHead, remaining); + otPlatUartReceived(sReceiveBuffer + sReceiveHead, remaining); sReceiveHead = 0; sReceiveLength -= remaining; } if (sReceiveLength > 0) { - otPlatSerialReceived(sReceiveBuffer + sReceiveHead, sReceiveLength); + otPlatUartReceived(sReceiveBuffer + sReceiveHead, sReceiveLength); sReceiveHead += sReceiveLength; sReceiveLength = 0; } @@ -155,13 +155,13 @@ void processTransmit(void) } sTransmitBuffer = NULL; - otPlatSerialSendDone(); + otPlatUartSendDone(); exit: return; } -void cc2538SerialProcess(void) +void cc2538UartProcess(void) { processReceive(); processTransmit(); diff --git a/examples/platforms/posix/Makefile.am b/examples/platforms/posix/Makefile.am index db4717ee2..1ce9f7e81 100644 --- a/examples/platforms/posix/Makefile.am +++ b/examples/platforms/posix/Makefile.am @@ -42,7 +42,7 @@ libopenthread_posix_a_SOURCES = \ platform.c \ radio.c \ random.c \ - serial.c \ + uart.c \ $(NULL) noinst_HEADERS = \ diff --git a/examples/platforms/posix/platform-posix.h b/examples/platforms/posix/platform-posix.h index 773d4659b..100713d43 100644 --- a/examples/platforms/posix/platform-posix.h +++ b/examples/platforms/posix/platform-posix.h @@ -100,19 +100,19 @@ void posixRadioProcess(void); void posixRandomInit(void); /** - * This function updates the file descriptor sets with file descriptors used by the serial driver. + * This function updates the file descriptor sets with file descriptors used by the UART driver. * * @param[inout] aReadFdSet A pointer to the read file descriptors. * @param[inout] aWriteFdSet A pointer to the write file descriptors. * @param[inout] aMaxFd A pointer to the max file descriptor. * */ -void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd); +void posixUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd); /** * This function performs radio driver processing. * */ -void posixSerialProcess(void); +void posixUartProcess(void); #endif // PLATFORM_POSIX_H_ diff --git a/examples/platforms/posix/platform.c b/examples/platforms/posix/platform.c index 6b2d71f63..64b9cdcd0 100644 --- a/examples/platforms/posix/platform.c +++ b/examples/platforms/posix/platform.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include "platform-posix.h" uint32_t NODE_ID = 1; @@ -59,7 +59,7 @@ void PlatformInit(int argc, char *argv[]) posixAlarmInit(); posixRadioInit(); posixRandomInit(); - otPlatSerialEnable(); + otPlatUartEnable(); } void PlatformProcessDrivers(void) @@ -73,7 +73,7 @@ void PlatformProcessDrivers(void) FD_ZERO(&read_fds); FD_ZERO(&write_fds); - posixSerialUpdateFdSet(&read_fds, &write_fds, &max_fd); + posixUartUpdateFdSet(&read_fds, &write_fds, &max_fd); posixRadioUpdateFdSet(&read_fds, &write_fds, &max_fd); posixAlarmUpdateTimeout(&timeout); @@ -83,7 +83,7 @@ void PlatformProcessDrivers(void) assert(rval >= 0 && errno != ETIME); } - posixSerialProcess(); + posixUartProcess(); posixRadioProcess(); posixAlarmProcess(); } diff --git a/examples/platforms/posix/serial.c b/examples/platforms/posix/uart.c similarity index 93% rename from examples/platforms/posix/serial.c rename to examples/platforms/posix/uart.c index 4654f0e49..9b4099c0a 100644 --- a/examples/platforms/posix/serial.c +++ b/examples/platforms/posix/uart.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include "platform-posix.h" #ifdef OPENTHREAD_TARGET_LINUX @@ -64,7 +64,7 @@ static void restore_stdout_termios(void) tcsetattr(s_out_fd, TCSAFLUSH, &original_stdout_termios); } -ThreadError otPlatSerialEnable(void) +ThreadError otPlatUartEnable(void) { ThreadError error = kThreadError_None; struct termios termios; @@ -140,7 +140,7 @@ exit: return error; } -ThreadError otPlatSerialDisable(void) +ThreadError otPlatUartDisable(void) { ThreadError error = kThreadError_None; @@ -150,7 +150,7 @@ ThreadError otPlatSerialDisable(void) return error; } -ThreadError otPlatSerialSend(const uint8_t *aBuf, uint16_t aBufLength) +ThreadError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength) { ThreadError error = kThreadError_None; @@ -163,7 +163,7 @@ exit: return error; } -void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd) +void posixUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd) { if (aReadFdSet != NULL) { @@ -186,7 +186,7 @@ void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd } } -void posixSerialProcess(void) +void posixUartProcess(void) { const int flags = POLLRDNORM | POLLERR | POLLNVAL | POLLHUP; struct pollfd pollfd = { s_in_fd, flags, 0 }; @@ -196,7 +196,7 @@ void posixSerialProcess(void) { rval = read(s_in_fd, s_receive_buffer, sizeof(s_receive_buffer)); assert(rval >= 0); - otPlatSerialReceived(s_receive_buffer, rval); + otPlatUartReceived(s_receive_buffer, rval); } if (s_write_length > 0) @@ -204,6 +204,6 @@ void posixSerialProcess(void) rval = write(s_out_fd, s_write_buffer, s_write_length); assert(rval >= 0); s_write_length = 0; - otPlatSerialSendDone(); + otPlatUartSendDone(); } } diff --git a/include/cli/Makefile.am b/include/cli/Makefile.am index 0bed6c48a..2be9dac90 100644 --- a/include/cli/Makefile.am +++ b/include/cli/Makefile.am @@ -29,7 +29,7 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am ot_cli_headers = \ - cli-serial.h \ + cli-uart.h \ $(NULL) ot_clidir = $(includedir)/cli diff --git a/include/cli/cli-serial.h b/include/cli/cli-uart.h similarity index 94% rename from include/cli/cli-serial.h rename to include/cli/cli-uart.h index f321d344d..ef7a48e2f 100644 --- a/include/cli/cli-serial.h +++ b/include/cli/cli-uart.h @@ -32,18 +32,18 @@ * This file defines the top-level functions for the OpenThread CLI server. */ -#ifndef CLI_SERIAL_H_ -#define CLI_SERIAL_H_ +#ifndef CLI_UART_H_ +#define CLI_UART_H_ #ifdef __cplusplus extern "C" { #endif /** - * Initialize the CLI serial server. + * Initialize the CLI UART module. * */ -void otCliSerialInit(void); +void otCliUartInit(void); #ifdef __cplusplus } // extern "C" diff --git a/include/ncp/ncp.h b/include/ncp/ncp.h index 437fe4e44..186250e23 100644 --- a/include/ncp/ncp.h +++ b/include/ncp/ncp.h @@ -29,7 +29,7 @@ /** * @file * @brief - * This file defines the top-level functions for the OpenThread CLI server. + * This file defines the top-level functions for the OpenThread NCP module. */ #ifndef NCP_H_ @@ -40,7 +40,7 @@ extern "C" { #endif /** - * Initialize the CLI serial server. + * Initialize the NCP. * */ void otNcpInit(void); diff --git a/include/platform/Makefile.am b/include/platform/Makefile.am index 087ae3086..d728984bc 100644 --- a/include/platform/Makefile.am +++ b/include/platform/Makefile.am @@ -33,7 +33,7 @@ ot_platform_headers =\ logging.h \ radio.h \ random.h \ - serial.h \ + uart.h \ spi-slave.h \ toolchain.h \ $(NULL) diff --git a/include/platform/serial.h b/include/platform/uart.h similarity index 65% rename from include/platform/serial.h rename to include/platform/uart.h index 510a46ef0..9e8f597f3 100644 --- a/include/platform/serial.h +++ b/include/platform/uart.h @@ -29,11 +29,11 @@ /** * @file * @brief - * This file includes the platform abstraction for serial communication. + * This file includes the platform abstraction for UART communication. */ -#ifndef SERIAL_H_ -#define SERIAL_H_ +#ifndef UART_H_ +#define UART_H_ #include @@ -44,57 +44,57 @@ extern "C" { #endif /** - * @defgroup serial Serial + * @defgroup uart UART * @ingroup platform * * @brief - * This module includes the platform abstraction for serial communication. + * This module includes the platform abstraction for UART communication. * * @{ * */ /** - * Enable the serial. + * Enable the UART. * - * @retval ::kThreadError_None Successfully enabled the serial. - * @retval ::kThreadError_Fail Failed to enabled the serial. + * @retval ::kThreadError_None Successfully enabled the UART. + * @retval ::kThreadError_Failed Failed to enabled the UART. */ -ThreadError otPlatSerialEnable(void); +ThreadError otPlatUartEnable(void); /** - * Disable the serial. + * Disable the UART. * - * @retval ::kThreadError_None Successfully disabled the serial. - * @retval ::kThreadError_Fail Failed to disable the serial. + * @retval ::kThreadError_None Successfully disabled the UART. + * @retval ::kThreadError_Failed Failed to disable the UART. */ -ThreadError otPlatSerialDisable(void); +ThreadError otPlatUartDisable(void); /** - * Send bytes over the serial. + * Send bytes over the UART. * * @param[in] aBuf A pointer to the data buffer. * @param[in] aBufLength Number of bytes to transmit. * - * @retval ::kThreadError_None Successfully started transmission. - * @retval ::kThreadError_Fail Failed to start the transmission. + * @retval ::kThreadError_None Successfully started transmission. + * @retval ::kThreadError_Failed Failed to start the transmission. */ -ThreadError otPlatSerialSend(const uint8_t *aBuf, uint16_t aBufLength); +ThreadError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength); /** - * The serial driver calls this method to notify OpenThread that the requested bytes have been sent. + * The UART driver calls this method to notify OpenThread that the requested bytes have been sent. * */ -extern void otPlatSerialSendDone(void); +extern void otPlatUartSendDone(void); /** - * The serial driver calls this method to notify OpenThread that bytes have been received. + * The UART driver calls this method to notify OpenThread that bytes have been received. * * @param[in] aBuf A pointer to the received bytes. * @param[in] aBufLength The number of bytes received. * */ -extern void otPlatSerialReceived(const uint8_t *aBuf, uint16_t aBufLength); +extern void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength); /** * @} @@ -105,4 +105,4 @@ extern void otPlatSerialReceived(const uint8_t *aBuf, uint16_t aBufLength); } // extern "C" #endif -#endif // SERIAL_H_ +#endif // UART_H_ diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index f2134e9ad..bbed129b2 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -39,13 +39,13 @@ libopenthread_cli_a_CPPFLAGS = \ libopenthread_cli_a_SOURCES = \ cli.cpp \ - cli_serial.cpp \ + cli_uart.cpp \ cli_udp.cpp \ $(NULL) noinst_HEADERS = \ cli.hpp \ - cli_serial.hpp \ + cli_uart.hpp \ cli_server.hpp \ cli_udp.hpp \ $(NULL) diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 0541d7f8b..dcfad09dd 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -40,7 +40,7 @@ #include "cli.hpp" #include -#include +#include using Thread::Encoding::BigEndian::HostSwap16; using Thread::Encoding::BigEndian::HostSwap32; diff --git a/src/cli/cli_serial.cpp b/src/cli/cli_uart.cpp similarity index 83% rename from src/cli/cli_serial.cpp rename to src/cli/cli_uart.cpp index 279246245..74e919670 100644 --- a/src/cli/cli_serial.cpp +++ b/src/cli/cli_uart.cpp @@ -28,7 +28,7 @@ /** * @file - * This file implements the CLI server on the serial service. + * This file implements the CLI server on the UART service. */ #include @@ -37,13 +37,13 @@ #include #include -#include -#include +#include +#include #include #include #include #include -#include +#include namespace Thread { namespace Cli { @@ -51,16 +51,16 @@ namespace Cli { static const char sCommandPrompt[] = {'>', ' '}; static const char sEraseString[] = {'\b', ' ', '\b'}; static const char CRNL[] = {'\r', '\n'}; -static Serial *sServer; +static Uart *sServer; -static otDEFINE_ALIGNED_VAR(sCliSerialRaw, sizeof(Serial), uint64_t); +static otDEFINE_ALIGNED_VAR(sCliUartRaw, sizeof(Uart), uint64_t); -extern "C" void otCliSerialInit(void) +extern "C" void otCliUartInit(void) { - sServer = new(&sCliSerialRaw) Serial; + sServer = new(&sCliUartRaw) Uart; } -Serial::Serial(void) +Uart::Uart(void) { mRxLength = 0; mTxHead = 0; @@ -68,12 +68,12 @@ Serial::Serial(void) mSendLength = 0; } -extern "C" void otPlatSerialReceived(const uint8_t *aBuf, uint16_t aBufLength) +extern "C" void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { sServer->ReceiveTask(aBuf, aBufLength); } -void Serial::ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength) +void Uart::ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength) { const uint8_t *end; @@ -115,7 +115,7 @@ void Serial::ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength) } } -ThreadError Serial::ProcessCommand(void) +ThreadError Uart::ProcessCommand(void) { ThreadError error = kThreadError_None; @@ -136,7 +136,7 @@ ThreadError Serial::ProcessCommand(void) return error; } -int Serial::Output(const char *aBuf, uint16_t aBufLength) +int Uart::Output(const char *aBuf, uint16_t aBufLength) { uint16_t remaining = kTxBufferSize - mTxLength; uint16_t tail; @@ -158,7 +158,7 @@ int Serial::Output(const char *aBuf, uint16_t aBufLength) return aBufLength; } -int Serial::OutputFormat(const char *fmt, ...) +int Uart::OutputFormat(const char *fmt, ...) { char buf[kMaxLineLength]; va_list ap; @@ -170,7 +170,7 @@ int Serial::OutputFormat(const char *fmt, ...) return Output(buf, strlen(buf)); } -void Serial::Send(void) +void Uart::Send(void) { VerifyOrExit(mSendLength == 0, ;); @@ -185,19 +185,19 @@ void Serial::Send(void) if (mSendLength > 0) { - otPlatSerialSend(reinterpret_cast(mTxBuffer + mTxHead), mSendLength); + otPlatUartSend(reinterpret_cast(mTxBuffer + mTxHead), mSendLength); } exit: return; } -extern "C" void otPlatSerialSendDone(void) +extern "C" void otPlatUartSendDone(void) { sServer->SendDoneTask(); } -void Serial::SendDoneTask(void) +void Uart::SendDoneTask(void) { mTxHead = (mTxHead + mSendLength) % kTxBufferSize; mTxLength -= mSendLength; diff --git a/src/cli/cli_serial.hpp b/src/cli/cli_uart.hpp similarity index 91% rename from src/cli/cli_serial.hpp rename to src/cli/cli_uart.hpp index 108461360..bf7126b98 100644 --- a/src/cli/cli_serial.hpp +++ b/src/cli/cli_uart.hpp @@ -28,11 +28,11 @@ /** * @file - * This file contains definitions for a CLI server on the serial service. + * This file contains definitions for a CLI server on the UART service. */ -#ifndef CLI_SERIAL_HPP_ -#define CLI_SERIAL_HPP_ +#ifndef CLI_UART_HPP_ +#define CLI_UART_HPP_ #include #include @@ -42,13 +42,13 @@ namespace Thread { namespace Cli { /** - * This class implements the CLI server on top of the serial platform abstraction. + * This class implements the CLI server on top of the UART platform abstraction. * */ -class Serial: public Server +class Uart: public Server { public: - Serial(void); + Uart(void); /** * This method delivers raw characters to the client. @@ -99,4 +99,4 @@ private: } // namespace Cli } // namespace Thread -#endif // CLI_SERIAL_HPP_ +#endif // CLI_UART_HPP_ diff --git a/src/ncp/ncp.cpp b/src/ncp/ncp.cpp index 6de1fbf67..903fe4050 100644 --- a/src/ncp/ncp.cpp +++ b/src/ncp/ncp.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include namespace Thread { @@ -128,7 +128,7 @@ Ncp::OutboundFrameSend(void) if (errorCode == kThreadError_None) { mSendFrameIter += outLength; - errorCode = otPlatSerialSend(mSendFrame, mSendFrameIter - mSendFrame); + errorCode = otPlatUartSend(mSendFrame, mSendFrameIter - mSendFrame); } if (errorCode == kThreadError_None) @@ -139,7 +139,7 @@ Ncp::OutboundFrameSend(void) return errorCode; } -extern "C" void otPlatSerialSendDone(void) +extern "C" void otPlatUartSendDone(void) { sNcp->SendDoneTask(); } @@ -151,7 +151,7 @@ void Ncp::SendDoneTask(void) super_t::HandleSendDone(); } -extern "C" void otPlatSerialReceived(const uint8_t *aBuf, uint16_t aBufLength) +extern "C" void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { sNcp->ReceiveTask(aBuf, aBufLength); } diff --git a/tests/unit/test_lowpan.cpp b/tests/unit/test_lowpan.cpp index f6d05372e..7f5fb926e 100644 --- a/tests/unit/test_lowpan.cpp +++ b/tests/unit/test_lowpan.cpp @@ -49,11 +49,11 @@ extern "C" bool otAreTaskletsPending(void) return false; } -extern "C" void otPlatSerialSendDone(void) +extern "C" void otPlatUartSendDone(void) { } -extern "C" void otPlatSerialReceived(const uint8_t *aBuf, uint16_t aBufLength) +extern "C" void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { }