Skip to content

Commit c611964

Browse files
committed
[update] 字符串写入(ab_cip_write_string)目前存在bug,待解决
There is currently a bug in string writing(ab_cip_write_string) that needs to be resolved.
1 parent a66ae1b commit c611964

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ cip_error_code_e ab_cip_write_int64(int fd, const char* address, int64 val); //
6464
cip_error_code_e ab_cip_write_uint64(int fd, const char* address, uint64 val); // 写入无符号64位整型
6565
cip_error_code_e ab_cip_write_float(int fd, const char* address, float val); // 写入浮点型
6666
cip_error_code_e ab_cip_write_double(int fd, const char* address, double val); // 写入双精度浮点型
67+
// 暂时不支持,存在bug
6768
cip_error_code_e ab_cip_write_string(int fd, const char* address, int length, const char* val); // 写入字符串
6869
```
6970

README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ cip_error_code_e ab_cip_write_int64(int fd, const char* address, int64 val); //
5757
cip_error_code_e ab_cip_write_uint64(int fd, const char* address, uint64 val); // Writes an unsigned 64-bit integer
5858
cip_error_code_e ab_cip_write_float(int fd, const char* address, float val); // Writes a floating-point value
5959
cip_error_code_e ab_cip_write_double(int fd, const char* address, double val); // Writes a double-precision floating-point value
60+
// Not supported at the moment, there is a bug
6061
cip_error_code_e ab_cip_write_string(int fd, const char* address, int length, const char* val); // Writes a string
6162
```
6263

ab_plc_cip_net/ab_cip.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ cip_error_code_e ab_cip_write_int64(int fd, const char* address, int64 val);
3535
cip_error_code_e ab_cip_write_uint64(int fd, const char* address, uint64 val);
3636
cip_error_code_e ab_cip_write_float(int fd, const char* address, float val);
3737
cip_error_code_e ab_cip_write_double(int fd, const char* address, double val);
38+
#if false
39+
// Not supported at the moment, there is a bug
3840
cip_error_code_e ab_cip_write_string(int fd, const char* address, int length, const char* val);
41+
#endif
3942

4043
#endif //__H_AB_CIP_H__

ab_plc_cip_net/main.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,6 @@ int main(int argc, char** argv)
4040
char address[50] = { 0 };
4141
int i = 0;
4242

43-
const char sz_write[] = "[email protected]";
44-
int length = strlen(sz_write);
45-
strcpy(address, "F");
46-
ret = ab_cip_write_string(fd, address, length, sz_write);
47-
printf("Write\t %s \tstring:\t %s, \tret: %d\n", address, sz_write, ret);
48-
GET_RESULT(ret);
49-
50-
char* str_val = NULL;
51-
strcpy(address, "F");
52-
ret = ab_cip_read_string(fd, address, &length, &str_val);
53-
printf("Read\t %s \tstring:\t %s\n", address, str_val);
54-
free(str_val);
55-
GET_RESULT(ret);
56-
57-
return 0;
58-
5943
for (i = 0; i < TEST_COUNT; i++)
6044
{
6145
printf("==============Test count: %d==============\n", i + 1);
@@ -174,13 +158,8 @@ int main(int argc, char** argv)
174158
#endif
175159
//////////////////////////////////////////////////////////////////////////
176160
#if true
177-
const char sz_write[] = "[email protected]";
178-
int length = strlen(sz_write);
161+
int length = 0;
179162
strcpy(address, "F");
180-
ret = ab_cip_write_string(fd, address, length, sz_write);
181-
printf("Write\t %s \tstring:\t %s, \tret: %d\n", address, sz_write, ret);
182-
GET_RESULT(ret);
183-
184163
char* str_val = NULL;
185164
ret = ab_cip_read_string(fd, address, &length, &str_val);
186165
printf("Read\t %s \tstring:\t %s\n", address, str_val);

0 commit comments

Comments
 (0)