| 86 | MSH_CMD_EXPORT(rtlink_fread, rtlink posix interface example); |
| 87 | |
| 88 | static void rtlink_fwrite(int argc, char *argv[]) |
| 89 | { |
| 90 | char *data = RT_NULL; |
| 91 | rt_size_t length = 0; |
| 92 | rt_uint16_t count = 0; |
| 93 | rt_size_t ret = 0; |
| 94 | |
| 95 | if (argc == 1) |
| 96 | { |
| 97 | data = rt_malloc(sizeof(TEST_CONTEXT)); |
| 98 | if (data) |
| 99 | { |
| 100 | length = sizeof(TEST_CONTEXT) - 1; |
| 101 | rt_memcpy(data, TEST_CONTEXT, sizeof(TEST_CONTEXT) - 1); |
| 102 | ret = write(fd, data, length); |
| 103 | } |
| 104 | LOG_I("write data(0x%p) result: %d.", data, ret); |
| 105 | } |
| 106 | else if (argc >= 3) |
| 107 | { |
| 108 | if (strcmp(argv[1], "-l") == 0) |
| 109 | { |
| 110 | data = rt_malloc(atoi((const char *)argv[2])); |
| 111 | if (data) |
| 112 | { |
| 113 | for (count = 0; count < atoi((const char *)argv[2]); count++) |
| 114 | { |
| 115 | data[count] = (count % 93 + 33); |
| 116 | } |
| 117 | length = atoi((const char *)argv[2]); |
| 118 | ret = write(fd, data, length); |
| 119 | } |
| 120 | LOG_I("write data(0x%p) result: %d.", data, ret); |
| 121 | } |
| 122 | else |
| 123 | { |
| 124 | LOG_E("Invalid parameter."); |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | MSH_CMD_EXPORT(rtlink_fwrite, rtlink posix interface example); |
| 129 | |
| 130 | #define RTLINK02 "rtlink02" |