summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorbernard <[email protected]>2014-11-01 21:52:26 +0800
committerbernard <[email protected]>2014-11-01 21:52:26 +0800
commita00cc57487f78629bf3aaa7c3c04708af6fa0800 (patch)
tree9ff51facb280baa4d427da3ad05bf07b70782876 /components
parentc7ee7f9858f2cc86d94a2eea8baacfc449865e9a (diff)
Prepare RT-Thread 1.2.3 release.
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/nfs/dfs_nfs.c11
-rw-r--r--components/dfs/src/dfs_file.c9
-rw-r--r--components/dfs/src/dfs_fs.c2
-rw-r--r--components/dfs/src/dfs_posix.c24
-rw-r--r--components/drivers/i2c/i2c-bit-ops.c3
-rw-r--r--components/drivers/i2c/i2c_core.c11
-rw-r--r--components/drivers/i2c/i2c_dev.c11
-rw-r--r--components/drivers/include/drivers/serial.h6
-rw-r--r--components/drivers/spi/spi_dev.c35
-rw-r--r--components/finsh/msh.c12
-rw-r--r--components/finsh/msh_cmd.c2
-rw-r--r--components/finsh/shell.c3
-rw-r--r--components/finsh/shell.h12
-rw-r--r--components/utilities/ymodem/ymodem.c7
14 files changed, 71 insertions, 77 deletions
diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c
index 5f03314309..7ff5fef5f7 100644
--- a/components/dfs/filesystems/nfs/dfs_nfs.c
+++ b/components/dfs/filesystems/nfs/dfs_nfs.c
@@ -750,11 +750,12 @@ int nfs_open(struct dfs_fd *file)
if (file->flags & DFS_O_CREAT)
{
if (nfs_mkdir(nfs, file->path, 0755) < 0)
- return -1;
+ return -DFS_STATUS_EAGAIN;
}
/* open directory */
dir = nfs_opendir(nfs, file->path);
+ if (dir == RT_NULL) return -DFS_STATUS_ENOENT;
file->data = dir;
}
else
@@ -766,20 +767,20 @@ int nfs_open(struct dfs_fd *file)
if (file->flags & DFS_O_CREAT)
{
if (nfs_create(nfs, file->path, 0664) < 0)
- return -1;
+ return -DFS_STATUS_EAGAIN;
}
/* open file (get file handle ) */
fp = rt_malloc(sizeof(nfs_file));
if (fp == RT_NULL)
- return -1;
+ return -DFS_STATUS_ENOMEM;
handle = get_handle(nfs, file->path);
if (handle == RT_NULL)
{
rt_free(fp);
- return -1;
+ return -DFS_STATUS_ENOENT;
}
/* get size of file */
@@ -798,7 +799,7 @@ int nfs_open(struct dfs_fd *file)
/* set private file */
file->data = fp;
- file->size = fp->size;
+ file->size = fp->size;
}
return 0;
diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c
index d1a47aa9fa..614a349494 100644
--- a/components/dfs/src/dfs_file.c
+++ b/components/dfs/src/dfs_file.c
@@ -335,6 +335,9 @@ int dfs_file_lseek(struct dfs_fd *fd, rt_off_t offset)
if (fd == RT_NULL)
return -DFS_STATUS_EINVAL;
+ fs = fd->fs;
+ if (fs == RT_NULL)
+ return -DFS_STATUS_EINVAL;
if (fs->ops->lseek == RT_NULL)
return -DFS_STATUS_ENOSYS;
@@ -555,7 +558,7 @@ void ls(const char *pathname)
if (pathname == RT_NULL)
rt_free(path);
}
-FINSH_FUNCTION_EXPORT(ls, list directory contents)
+FINSH_FUNCTION_EXPORT(ls, list directory contents);
void rm(const char *filename)
{
@@ -564,7 +567,7 @@ void rm(const char *filename)
rt_kprintf("Delete %s failed\n", filename);
}
}
-FINSH_FUNCTION_EXPORT(rm, remove files or directories)
+FINSH_FUNCTION_EXPORT(rm, remove files or directories);
void cat(const char* filename)
{
@@ -590,7 +593,7 @@ void cat(const char* filename)
dfs_file_close(&fd);
}
-FINSH_FUNCTION_EXPORT(cat, print file)
+FINSH_FUNCTION_EXPORT(cat, print file);
#define BUF_SZ 4096
static void copyfile(const char *src, const char *dst)
diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c
index 406403e51e..a41f36cf09 100644
--- a/components/dfs/src/dfs_fs.c
+++ b/components/dfs/src/dfs_fs.c
@@ -85,6 +85,8 @@ struct dfs_filesystem *dfs_filesystem_lookup(const char *path)
prefixlen = 0;
+ RT_ASSERT(path);
+
/* lock filesystem */
dfs_lock();
diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c
index 96139837e9..c1a6a5beb6 100644
--- a/components/dfs/src/dfs_posix.c
+++ b/components/dfs/src/dfs_posix.c
@@ -33,11 +33,11 @@
/**
* this function is a POSIX compliant version, which will open a file and
- * return a file descriptor.
+ * return a file descriptor according specified flags.
*
* @param file the path name of file.
* @param flags the file open flags.
- * @param mode
+ * @param mode ignored parameter
*
* @return the non-negative integer on successful open, others for failed.
*/
@@ -120,7 +120,8 @@ RTM_EXPORT(close);
* @param buf the buffer to save the read data.
* @param len the maximal length of data buffer
*
- * @return the actual read data buffer length
+ * @return the actual read data buffer length. If the returned value is 0, it
+ * may be reach the end of file, please check errno.
*/
int read(int fd, void *buf, size_t len)
{
@@ -200,7 +201,7 @@ RTM_EXPORT(write);
* @param offset the offset to be seeked.
* @param whence the directory of seek.
*
- * @return the current file position, or -1 on failed.
+ * @return the current read/write position in the file, or -1 on failed.
*/
off_t lseek(int fd, off_t offset, int whence)
{
@@ -336,6 +337,8 @@ RTM_EXPORT(stat);
*
* @param fildes the file description
* @param buf the data buffer to save stat description.
+ *
+ * @return 0 on successful, -1 on failed.
*/
int fstat(int fildes, struct stat *buf)
{
@@ -470,7 +473,7 @@ RTM_EXPORT(rmdir);
*
* @param name the path name to be open.
*
- * @return the DIR pointer of directory, NULL on open failed.
+ * @return the DIR pointer of directory, NULL on open directory failed.
*/
DIR *opendir(const char *name)
{
@@ -537,12 +540,17 @@ struct dirent *readdir(DIR *d)
if (fd == RT_NULL)
{
rt_set_errno(-DFS_STATUS_EBADF);
-
return RT_NULL;
}
- if (!d->num ||
- (d->cur += ((struct dirent *)(d->buf + d->cur))->d_reclen) >= d->num)
+ if (d->num)
+ {
+ struct dirent* dirent_ptr;
+ dirent_ptr = (struct dirent*)&d->buf[d->cur];
+ d->cur += dirent_ptr->d_reclen;
+ }
+
+ if (!d->num || d->cur >= d->num)
{
/* get a new entry */
result = dfs_file_getdents(fd,
diff --git a/components/drivers/i2c/i2c-bit-ops.c b/components/drivers/i2c/i2c-bit-ops.c
index 0d82d55fd4..d4a26ea72a 100644
--- a/components/drivers/i2c/i2c-bit-ops.c
+++ b/components/drivers/i2c/i2c-bit-ops.c
@@ -451,9 +451,6 @@ static const struct rt_i2c_bus_device_ops i2c_bit_bus_ops =
rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus,
const char *bus_name)
{
- struct rt_i2c_bit_ops *bit_ops = bus->priv;
- RT_ASSERT(bit_ops != RT_NULL);
-
bus->ops = &i2c_bit_bus_ops;
return rt_i2c_bus_device_register(bus, bus_name);
diff --git a/components/drivers/i2c/i2c_core.c b/components/drivers/i2c/i2c_core.c
index f274f70fcd..09616235d1 100644
--- a/components/drivers/i2c/i2c_core.c
+++ b/components/drivers/i2c/i2c_core.c
@@ -24,8 +24,6 @@
#include <rtdevice.h>
-static struct rt_mutex i2c_core_lock;
-
rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus,
const char *bus_name)
{
@@ -33,17 +31,12 @@ rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus,
rt_mutex_init(&bus->lock, "i2c_bus_lock", RT_IPC_FLAG_FIFO);
- rt_mutex_take(&i2c_core_lock, RT_WAITING_FOREVER);
-
- if (bus->timeout == 0)
- bus->timeout = RT_TICK_PER_SECOND;
+ if (bus->timeout == 0) bus->timeout = RT_TICK_PER_SECOND;
res = rt_i2c_bus_device_device_init(bus, bus_name);
i2c_dbg("I2C bus [%s] registered\n", bus_name);
- rt_mutex_release(&i2c_core_lock);
-
return res;
}
@@ -136,6 +129,6 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
int rt_i2c_core_init(void)
{
- return rt_mutex_init(&i2c_core_lock, "i2c_core_lock", RT_IPC_FLAG_FIFO);
+ return 0;
}
INIT_COMPONENT_EXPORT(rt_i2c_core_init);
diff --git a/components/drivers/i2c/i2c_dev.c b/components/drivers/i2c/i2c_dev.c
index cce53d5c92..4b811c62ea 100644
--- a/components/drivers/i2c/i2c_dev.c
+++ b/components/drivers/i2c/i2c_dev.c
@@ -20,18 +20,11 @@
* Change Logs:
* Date Author Notes
* 2012-04-25 weety first version
+ * 2014-08-03 bernard fix some compiling warning
*/
#include <rtdevice.h>
-static rt_err_t i2c_bus_device_init(rt_device_t dev)
-{
- struct rt_i2c_bus_device *bus = (struct rt_i2c_bus_device *)dev->user_data;
- RT_ASSERT(bus != RT_NULL);
-
- return RT_EOK;
-}
-
static rt_size_t i2c_bus_device_read(rt_device_t dev,
rt_off_t pos,
void *buffer,
@@ -122,7 +115,7 @@ rt_err_t rt_i2c_bus_device_device_init(struct rt_i2c_bus_device *bus,
/* set device type */
device->type = RT_Device_Class_I2CBUS;
/* initialize device interface */
- device->init = i2c_bus_device_init;
+ device->init = RT_NULL;
device->open = RT_NULL;
device->close = RT_NULL;
device->read = i2c_bus_device_read;
diff --git a/components/drivers/include/drivers/serial.h b/components/drivers/include/drivers/serial.h
index 41132ed916..9655820736 100644
--- a/components/drivers/include/drivers/serial.h
+++ b/components/drivers/include/drivers/serial.h
@@ -30,9 +30,15 @@
#include <rtthread.h>
+#define BAUD_RATE_2400 2400
#define BAUD_RATE_4800 4800
#define BAUD_RATE_9600 9600
+#define BAUD_RATE_38400 38400
+#define BAUD_RATE_57600 57600
#define BAUD_RATE_115200 115200
+#define BAUD_RATE_230400 230400
+#define BAUD_RATE_460800 460800
+#define BAUD_RATE_921600 921600
#define DATA_BITS_5 5
#define DATA_BITS_6 6
diff --git a/components/drivers/spi/spi_dev.c b/components/drivers/spi/spi_dev.c
index b1f6e41a86..375a5e0fa1 100644
--- a/components/drivers/spi/spi_dev.c
+++ b/components/drivers/spi/spi_dev.c
@@ -25,16 +25,6 @@
#include <drivers/spi.h>
/* SPI bus device interface, compatible with RT-Thread 0.3.x/1.0.x */
-static rt_err_t _spi_bus_device_init(rt_device_t dev)
-{
- struct rt_spi_bus *bus;
-
- bus = (struct rt_spi_bus *)dev;
- RT_ASSERT(bus != RT_NULL);
-
- return RT_EOK;
-}
-
static rt_size_t _spi_bus_device_read(rt_device_t dev,
rt_off_t pos,
void *buffer,
@@ -67,11 +57,7 @@ static rt_err_t _spi_bus_device_control(rt_device_t dev,
rt_uint8_t cmd,
void *args)
{
- struct rt_spi_bus *bus;
-
- bus = (struct rt_spi_bus *)dev;
- RT_ASSERT(bus != RT_NULL);
-
+ /* TODO: add control command handle */
switch (cmd)
{
case 0: /* set device */
@@ -93,7 +79,7 @@ rt_err_t rt_spi_bus_device_init(struct rt_spi_bus *bus, const char *name)
/* set device type */
device->type = RT_Device_Class_SPIBUS;
/* initialize device interface */
- device->init = _spi_bus_device_init;
+ device->init = RT_NULL;
device->open = RT_NULL;
device->close = RT_NULL;
device->read = _spi_bus_device_read;
@@ -105,16 +91,6 @@ rt_err_t rt_spi_bus_device_init(struct rt_spi_bus *bus, const char *name)
}
/* SPI Dev device interface, compatible with RT-Thread 0.3.x/1.0.x */
-static rt_err_t _spidev_device_init(rt_device_t dev)
-{
- struct rt_spi_device *device;
-
- device = (struct rt_spi_device *)dev;
- RT_ASSERT(device != RT_NULL);
-
- return RT_EOK;
-}
-
static rt_size_t _spidev_device_read(rt_device_t dev,
rt_off_t pos,
void *buffer,
@@ -147,11 +123,6 @@ static rt_err_t _spidev_device_control(rt_device_t dev,
rt_uint8_t cmd,
void *args)
{
- struct rt_spi_device *device;
-
- device = (struct rt_spi_device *)dev;
- RT_ASSERT(device != RT_NULL);
-
switch (cmd)
{
case 0: /* set device */
@@ -172,7 +143,7 @@ rt_err_t rt_spidev_device_init(struct rt_spi_device *dev, const char *name)
/* set device type */
device->type = RT_Device_Class_SPIDevice;
- device->init = _spidev_device_init;
+ device->init = RT_NULL;
device->open = RT_NULL;
device->close = RT_NULL;
device->read = _spidev_device_read;
diff --git a/components/finsh/msh.c b/components/finsh/msh.c
index 49a5d23591..02cbeea196 100644
--- a/components/finsh/msh.c
+++ b/components/finsh/msh.c
@@ -315,12 +315,15 @@ int msh_exec(char* cmd, rt_size_t length)
return 0;
}
#endif
-#ifdef DFS_USING_WORKDIR
+
+#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
+ /* change to this directory */
if (chdir(cmd) == 0)
{
return 0;
}
#endif
+
/* truncate the cmd at the first space. */
{
char *tcmd;
@@ -355,10 +358,12 @@ void msh_auto_complete_path(char *path)
struct dirent *dirent = RT_NULL;
char *full_path, *ptr, *index;
+ if (!path)
+ return;
+
full_path = (char*)rt_malloc(256);
if (full_path == RT_NULL) return; /* out of memory */
- ptr = full_path;
if (*path != '/')
{
getcwd(full_path, 256);
@@ -367,7 +372,8 @@ void msh_auto_complete_path(char *path)
}
else *full_path = '\0';
- index = RT_NULL; ptr = path;
+ index = RT_NULL;
+ ptr = path;
for (;;)
{
if (*ptr == '/') index = ptr + 1; if (!*ptr) break; ptr ++;
diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c
index c11873dc91..a5ccf538b8 100644
--- a/components/finsh/msh_cmd.c
+++ b/components/finsh/msh_cmd.c
@@ -206,6 +206,7 @@ int cmd_time(int argc, char** argv)
}
FINSH_FUNCTION_EXPORT_ALIAS(cmd_time, __cmd_time, Execute command with time.);
+#ifdef RT_USING_HEAP
int cmd_free(int argc, char** argv)
{
extern void list_mem(void);
@@ -214,6 +215,7 @@ int cmd_free(int argc, char** argv)
return 0;
}
FINSH_FUNCTION_EXPORT_ALIAS(cmd_free, __cmd_free, Show the memory usage in the system.);
+#endif
#endif
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index ae099e7e7c..5a6bfc1104 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -70,10 +70,11 @@ const char* finsh_get_prompt()
#endif
strcpy(finsh_prompt, _PROMPT);
-#ifdef DFS_USING_WORKDIR
+#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
/* get current working directory */
getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
#endif
+
strcat(finsh_prompt, ">");
return finsh_prompt;
diff --git a/components/finsh/shell.h b/components/finsh/shell.h
index 448f9e6fbe..92fa4bccb2 100644
--- a/components/finsh/shell.h
+++ b/components/finsh/shell.h
@@ -33,7 +33,17 @@
#include <rtthread.h>
#include "finsh.h"
-#define FINSH_USING_HISTORY
+/* For historical reasons, users don't define FINSH_USING_HISTORY in rtconfig.h
+ * but expect the history feature. So you sould define FINSH_USING_HISTORY to 0
+ * to disable it from the rtconfig.h. */
+#ifdef FINSH_USING_HISTORY
+# if FINSH_USING_HISTORY == 0
+# undef FINSH_USING_HISTORY
+# endif
+#else
+# define FINSH_USING_HISTORY
+#endif
+
#ifndef FINSH_THREAD_PRIORITY
#define FINSH_THREAD_PRIORITY 20
#endif
diff --git a/components/utilities/ymodem/ymodem.c b/components/utilities/ymodem/ymodem.c
index f5ebeab832..3af1528024 100644
--- a/components/utilities/ymodem/ymodem.c
+++ b/components/utilities/ymodem/ymodem.c
@@ -197,7 +197,7 @@ static rt_err_t _rym_do_trans(struct rym_ctx *ctx)
{
rt_err_t err;
enum rym_code code;
- rt_size_t data_sz;
+ rt_size_t data_sz, i;
code = _rym_read_code(ctx,
RYM_WAIT_PKG_TICK);
@@ -223,8 +223,9 @@ static rt_err_t _rym_do_trans(struct rym_ctx *ctx)
{
case RYM_CODE_CAN:
/* the spec require multiple CAN */
- _rym_putchar(ctx, RYM_CODE_CAN);
- _rym_putchar(ctx, RYM_CODE_CAN);
+ for (i = 0; i < RYM_END_SESSION_SEND_CAN_NUM; i++) {
+ _rym_putchar(ctx, RYM_CODE_CAN);
+ }
return -RYM_ERR_CAN;
case RYM_CODE_ACK:
_rym_putchar(ctx, RYM_CODE_ACK);