Fix nxstyle warning

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-03-20 01:25:22 +08:00 committed by patacongo
parent 86080a110e
commit f3c104b99a
6 changed files with 55 additions and 33 deletions

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/examples/modbus/main.c
* apps/examples/modbus/modbus_main.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -140,7 +140,10 @@ static void modbus_showusage(FAR const char *progname, int exitcode);
****************************************************************************/
static struct modbus_state_s g_modbus;
static const uint8_t g_slaveid[] = { 0xaa, 0xbb, 0xcc };
static const uint8_t g_slaveid[] =
{
0xaa, 0xbb, 0xcc
};
/****************************************************************************
* Private Functions
@ -191,7 +194,8 @@ static inline int modbus_initialize(void)
*/
mberr = eMBInit(MB_RTU, 0x0a, CONFIG_EXAMPLES_MODBUS_PORT,
CONFIG_EXAMPLES_MODBUS_BAUD, CONFIG_EXAMPLES_MODBUS_PARITY);
CONFIG_EXAMPLES_MODBUS_BAUD,
CONFIG_EXAMPLES_MODBUS_PARITY);
if (mberr != MB_ENOERR)
{
fprintf(stderr, "modbus_main: "
@ -231,6 +235,7 @@ static inline int modbus_initialize(void)
return OK;
errout_with_modbus:
/* Release hardware resources. */
eMBClose();
@ -376,7 +381,8 @@ static inline int modbus_create_pollthread(void)
if (g_modbus.threadstate == STOPPED)
{
ret = pthread_create(&g_modbus.threadid, NULL, modbus_pollthread, NULL);
ret = pthread_create(&g_modbus.threadid, NULL,
modbus_pollthread, NULL);
}
else
{
@ -444,7 +450,8 @@ int main(int argc, FAR char *argv[])
if (ret != OK)
{
fprintf(stderr, "modbus_main: "
"ERROR: modbus_create_pollthread failed: %d\n", ret);
"ERROR: modbus_create_pollthread failed: %d\n",
ret);
exit(EXIT_FAILURE);
}
}
@ -536,8 +543,8 @@ eMBErrorCode eMBRegInputCB(uint8_t *buffer, uint16_t address, uint16_t nregs)
*
****************************************************************************/
eMBErrorCode eMBRegHoldingCB(uint8_t *buffer, uint16_t address, uint16_t nregs,
eMBRegisterMode mode)
eMBErrorCode eMBRegHoldingCB(uint8_t *buffer, uint16_t address,
uint16_t nregs, eMBRegisterMode mode)
{
eMBErrorCode mberr = MB_ENOERR;
int index;
@ -551,6 +558,7 @@ eMBErrorCode eMBRegHoldingCB(uint8_t *buffer, uint16_t address, uint16_t nregs,
switch (mode)
{
/* Pass current register values to the protocol stack. */
case MB_REG_READ:
while (nregs > 0)
{
@ -592,8 +600,8 @@ eMBErrorCode eMBRegHoldingCB(uint8_t *buffer, uint16_t address, uint16_t nregs,
*
****************************************************************************/
eMBErrorCode eMBRegCoilsCB(uint8_t *buffer, uint16_t address, uint16_t ncoils,
eMBRegisterMode mode)
eMBErrorCode eMBRegCoilsCB(uint8_t *buffer, uint16_t address,
uint16_t ncoils, eMBRegisterMode mode)
{
eMBErrorCode mberr = MB_ENOERR;
int index;
@ -649,7 +657,8 @@ eMBErrorCode eMBRegCoilsCB(uint8_t *buffer, uint16_t address, uint16_t ncoils,
*
****************************************************************************/
eMBErrorCode eMBRegDiscreteCB(uint8_t *buffer, uint16_t address, uint16_t ndiscrete)
eMBErrorCode eMBRegDiscreteCB(uint8_t *buffer, uint16_t address,
uint16_t ndiscrete)
{
return MB_ENOREG;
}

View File

@ -13,8 +13,8 @@
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
@ -69,20 +69,24 @@
struct FileStream
{
int dev,tty;
int dev;
int tty;
int recLength;
int infd;
char inBuf[1024];
size_t inSize,inCapacity;
size_t inSize;
size_t inCapacity;
int outfd;
int outPos;
int outLineWidth;
int outColWidth;
char outBuf[1024];
size_t outSize,outCapacity;
int outforeground,outbackground;
size_t outSize;
size_t outCapacity;
int outforeground;
int outbackground;
int randomfd;
int recPos;

View File

@ -214,7 +214,8 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
}
else if (tcgetattr(iSerialFd, &xOldTIO) != 0)
{
vMBPortLog(MB_LOG_ERROR, "SER-INIT", "Can't get settings from port %s: %d\n",
vMBPortLog(MB_LOG_ERROR,
"SER-INIT", "Can't get settings from port %s: %d\n",
szDevice, errno);
}
else
@ -261,22 +262,24 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
*
* (1) In NuttX, cfset[i|o]speed always return OK so failures will
* really only be reported when tcsetattr() is called.
* (2) NuttX does not support separate input and output speeds so it
* is not necessary to call both cfsetispeed() and
* (2) NuttX does not support separate input and output speeds so
* it is not necessary to call both cfsetispeed() and
* cfsetospeed(), and
* (3) In NuttX, the input value to cfiset[i|o]speed is not
* encoded, but is the absolute baud value. The following might
* not be
* encoded, but is the absolute baud value. The following
* might not be
*/
if (cfsetispeed(&xNewTIO, ulBaudRate) != 0 /* || cfsetospeed(&xNewTIO, ulBaudRate) != 0 */)
{
vMBPortLog(MB_LOG_ERROR, "SER-INIT", "Can't set baud rate %ld for port %s: %d\n",
vMBPortLog(MB_LOG_ERROR, "SER-INIT",
"Can't set baud rate %ld for port %s: %d\n",
ulBaudRate, szDevice, errno);
}
else if (tcsetattr(iSerialFd, TCSANOW, &xNewTIO) != 0)
{
vMBPortLog(MB_LOG_ERROR, "SER-INIT", "Can't set settings for port %s: %d\n",
vMBPortLog(MB_LOG_ERROR,
"SER-INIT", "Can't set settings for port %s: %d\n",
szDevice, errno);
}
else
@ -344,7 +347,8 @@ bool xMBPortSerialPoll(void)
}
else
{
vMBPortLog(MB_LOG_ERROR, "SER-POLL", "read failed on serial device: %d\n",
vMBPortLog(MB_LOG_ERROR,
"SER-POLL", "read failed on serial device: %d\n",
errno);
bStatus = false;
}
@ -361,7 +365,8 @@ bool xMBPortSerialPoll(void)
if (!prvbMBPortSerialWrite(&ucBuffer[0], uiTxBufferPos))
{
vMBPortLog(MB_LOG_ERROR, "SER-POLL", "write failed on serial device: %d\n",
vMBPortLog(MB_LOG_ERROR,
"SER-POLL", "write failed on serial device: %d\n",
errno);
bStatus = false;
}

View File

@ -87,7 +87,8 @@ static struct termios xOldTIO;
static bool prvbMBMasterPortSerialRead(uint8_t *pucBuffer, uint16_t usNBytes,
uint16_t *usNBytesRead);
static bool prvbMBMasterPortSerialWrite(uint8_t *pucBuffer, uint16_t usNBytes);
static bool prvbMBMasterPortSerialWrite(uint8_t *pucBuffer,
uint16_t usNBytes);
/****************************************************************************
* Private Functions
@ -142,7 +143,8 @@ static bool prvbMBMasterPortSerialRead(uint8_t *pucBuffer, uint16_t usNBytes,
return bResult;
}
static bool prvbMBMasterPortSerialWrite(uint8_t *pucBuffer, uint16_t usNBytes)
static bool prvbMBMasterPortSerialWrite(uint8_t *pucBuffer,
uint16_t usNBytes)
{
ssize_t res;
size_t left = (size_t) usNBytes;
@ -268,12 +270,12 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate,
*
* (1) In NuttX, cfset[i|o]speed always return OK so failures will
* really only be reported when tcsetattr() is called.
* (2) NuttX does not support separate input and output speeds so it
* is not necessary to call both cfsetispeed() and
* (2) NuttX does not support separate input and output speeds so
* it is not necessary to call both cfsetispeed() and
* cfsetospeed(), and
* (3) In NuttX, the input value to cfiset[i|o]speed is not
* encoded, but is the absolute baud value. The following might
* not be
* encoded, but is the absolute baud value. The following
* might not be
*/
if (cfsetispeed(&xNewTIO, ulBaudRate) != 0 /* || cfsetospeed(&xNewTIO, ulBaudRate) != 0 */)

View File

@ -160,6 +160,7 @@ errout_with_zmodem:
zmr_release(handle);
errout_with_device:
/* Flush the serial output to assure do not hang trying to drain it */
tcflush(fd, TCIOFLUSH);

View File

@ -260,6 +260,7 @@ errout_with_zmodem:
zms_release(handle);
errout_with_device:
/* Flush the serial output to assure do not hang trying to drain it */
tcflush(fd, TCIOFLUSH);