Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TCP client cannot send read only data #16541

@kex2017

Description

@kex2017

Description

TCP client cannot send read only data

Steps to reproduce the issue

hardware:stm32f407ze
usemodule:stm32_eth
test ipv4 tcp client send const data like this "const char sendbuf[] = "Hello!";"
The test code is as follows:
`
const char sendbuf[] = "Hello!";
int test_tcp_client(void)
{
int res = 0;
sock_tcp_t sock;
sock_tcp_ep_t remote = SOCK_IPV4_EP_ANY;

remote.port = SERVER_PORT;//SERVER_PORT=12345

ipv4_addr_from_str((ipv4_addr_t *)&remote.addr, SERVER_IP_ADDR);//SERVER_IP_ADDR=192.168.12.89
xtimer_sleep(2);

if (sock_tcp_connect(&sock, &remote, 0, 0) < 0)
{
    puts("Error connecting sock");
    return 1;
}

puts("Sending \"Hello!\"");
if ((res = sock_tcp_write(&sock, sendbuf, sizeof(sendbuf))) < 0)
{
    puts("Errored on write");
}
puts("send over...");

`
However, if the data sent is modified to "char sendbuf[] = "Hello!";", without "const",it will be sent successfully

Expected results

Actual results

Versions

Operating System Environment

     Operating System: "Ubuntu" "18.04.5 LTS (Bionic Beaver)"
               Kernel: Linux 5.4.0-73-generic x86_64 x86_64
         System shell: /bin/dash (probably dash)
         make's shell: /bin/dash (probably dash)

Installed compiler toolchains

           native gcc: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
    arm-none-eabi-gcc: arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]
              avr-gcc: missing
     mips-mti-elf-gcc: missing
       msp430-elf-gcc: missing
   riscv-none-elf-gcc: missing

riscv64-unknown-elf-gcc: missing
riscv-none-embed-gcc: missing
xtensa-esp32-elf-gcc: missing
xtensa-esp8266-elf-gcc: missing
clang: missing

Installed compiler libs

 arm-none-eabi-newlib: "3.0.0"
  mips-mti-elf-newlib: missing
    msp430-elf-newlib: missing
riscv-none-elf-newlib: missing

riscv64-unknown-elf-newlib: missing
riscv-none-embed-newlib: missing
xtensa-esp32-elf-newlib: missing
xtensa-esp8266-elf-newlib: missing
avr-libc: missing (missing)

Installed development tools

               ccache: missing
                cmake: cmake version 3.10.2
             cppcheck: missing
              doxygen: 1.8.13
                  git: git version 2.17.1
                 make: GNU Make 4.1
              openocd: missing
               python: Python 2.7.17
              python2: Python 2.7.17
              python3: Python 3.6.9
               flake8: error: /usr/bin/python3: No module named flake8
           coccinelle: missing

Metadata

Metadata

Assignees

Labels

Area: driversArea: Device driversType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions