forked from xuos/xiuos
Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into jerryscript
This commit is contained in:
commit
29499a1ec3
|
@ -190,3 +190,33 @@ int SerialRead(uint8_t *read_data, int length)
|
|||
return data_size;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ControlFileDataStore(uint8 *data, int data_length)
|
||||
{
|
||||
int data_file_fd = -1;
|
||||
struct stat data_file_status;
|
||||
int i = 0;
|
||||
|
||||
//Step1 : open data file from SD card or other store device
|
||||
data_file_fd = PrivOpen(FILE_NAME, O_RDONLY);
|
||||
if (data_file_fd < 0) {
|
||||
printf("Open data file %s failed\n", FILE_NAME);
|
||||
PrivClose(data_file_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != fstat(data_file_fd, &data_file_status)) {
|
||||
printf("Get data file information failed!\n");
|
||||
PrivClose(data_file_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lseek(data_file_fd, data_file_status.st_size, SEEK_SET);
|
||||
|
||||
//Step2 : write data to file in SD card or other store device
|
||||
FatfsPrintf(GetFileDescriptor(data_file_fd), data, data_length);
|
||||
|
||||
//Step3 : close data file from SD card or other store device
|
||||
PrivClose(data_file_fd);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,9 @@ extern "C" {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define FILE_NAME "plc_data.csv"
|
||||
extern void FatfsPrintf(struct FileDescriptor *fdp, const void *src, size_t len);
|
||||
|
||||
/*Control Framework Socket Init*/
|
||||
void SocketInit(char *ip, char *mask, char *gw);
|
||||
|
||||
|
@ -60,6 +63,9 @@ void SerialWrite(uint8_t *write_data, int length);
|
|||
/*Control Framework Serial Read*/
|
||||
int SerialRead(uint8_t *read_data, int length);
|
||||
|
||||
/*Control Framework Store data in SD Card*/
|
||||
int ControlFileDataStore(uint8 *data, int data_length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -493,3 +493,15 @@ DWORD GetFatTime(void)
|
|||
|
||||
return fat_time;
|
||||
}
|
||||
|
||||
void FatfsPrintf(struct FileDescriptor *fdp, const void *src, size_t len)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < len; i ++) {
|
||||
f_printf(fdp->data, "%d,", ((uint8 *)src)[i]);
|
||||
}
|
||||
if (i == len) {
|
||||
f_printf(fdp->data, "\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define FF_USE_STRFUNC 0
|
||||
#define FF_USE_STRFUNC 1
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
|
|
Loading…
Reference in New Issue