FreeRTOS Win32 simulator C++

Hi CHING-HSIN LEE,

The project FreeRTOSPlusTCPMinimal does compile but not running.

It says wpcap.dll is missing. But I have installed both for x86 and x64, installing Wireshark.

I checked under windows directory and they are.

This is the output of Visual studio when I ran the application

FreeRTOS_Plus_TCP_Minimal.exe’ (Win32): Loaded ‘C:\FreeRTOSv202212.00\FreeRTOS-Plus\Demo\FreeRTOS_Plus_TCP_Minimal_Windows_Simulator\Debug\FreeRTOS_Plus_TCP_Minimal.exe’. Symbols loaded.

‘FreeRTOS_Plus_TCP_Minimal.exe’ (Win32): Loaded ‘C:\Windows\SysWOW64\ntdll.dll’.

‘FreeRTOS_Plus_TCP_Minimal.exe’ (Win32): Loaded ‘C:\Windows\SysWOW64\kernel32.dll’.

‘FreeRTOS_Plus_TCP_Minimal.exe’ (Win32): Loaded ‘C:\Windows\SysWOW64\KernelBase.dll’.

The thread 0x20d4 has exited with code -1073741515 (0xc0000135).

The program ‘[4648] FreeRTOS_Plus_TCP_Minimal.exe’ has exited with code -1073741515 (0xc0000135) ‘A dependent dll was not found’.

The dependent dll is wpcap.dll.

I have made a porting to MingW, it compiles but id does run too. I suppose the problem is the same. But no messages as in Visual Studio.

Do you have any idea?

Best Regards

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

The demo needs WINPCAP, but the development of that driver has stopped.

What I did is using Npcap in WinPcap API-compatible mode:

image

Note that Npcap is also used by Wireshark.

Hi Fortunato,

Please give it a try with Hein’s suggestion and feed back further question.
We will keep following your questions in this thread.

Hi, CHING-HSIN LEE,

Yes, I followed Hien’s suggestion. Visual studio told me that miss wpcap.dll library

While eclipse just aborted. I had installed wireshark but was not enough. I had to

install from the site and use windows installer.

Now It looks like it compiles and start, infact

FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); does not crash.

I have two other question, after FreeRTOS_IPInit, every TCP/IP task is initialized and running and I can use the TCP API?

Like open socket listen accept bind and so on?

ucIPAddress , ucNetMask,…. which are defined are the ipAddress mask… and so on of the simulator, not of the pc on

which I run. Correct?

Best Regards

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi @Fortunato,

Yes, you can open/listen/bind socket after FreeRTOS_IPInit. But full stack functionalities would be in task level (after vTaskStartScheduler).

Yes, the IP address is set for the simulator only. But the stack may be using same network interface on your PC if you don’t have multiple interfaces.

Thanks.

Hi CHING-HSING LEE,

I have had a reply from ActoryOu, and used his suggestion.

Should I reply to his mail or to your?

Anyway, I have used the sample code to accept a connection vCreateTCPClientSocket function.

But unfortunately after binding it remains correctly blocked on FreeRTOS_accept.

I have a simple TCPClient in C# that I use to connect to other devices, so I know it works.

But here It doesn’t. I tried to ping the simulator IP address and it says unreachable.

There is still something wrong in my porting. But I have no idea what it is.

Best

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi, CHING-HSIN LEE,

forget my previous email. I made an error defining ipconfigUSE_DHCP in the wrong place.

Now it works correctly.

I am going on and if I found other problems I will ask you.

For now everything ok. Thank you very much.

Best Regards

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

1 Like

Hello CHING-HSIN Lee,

It looks I have a speed problem

I have to transfer an Image(480x272 rgb555) using FreeRTOS_send.

I send this data as chunk of 16320 bytes and everytime FreeRTOS_send returns

correctly the number of bytes I wanted to send. My C# program receiver gets all

the bytes but they arrive after a lot of time, ten seconds. Is there a way to speed up?

What does this delay depends on? Thank in advance for the reply. I am looking forward to read it.

Best Regards

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi @Fortunato,
Thanks for your feedback.
First of all, could you help to share your device log?

Second, I currently suspect that IP task used by TCP stack has few CPU time to run. Could you help to add delay after sending data and monitor if IP task is running?

Thanks.
BR,
Actory

Hi ActoryOu,

your request finds me in difficult, I have no idea where and how to log, but will be very

glad if you suggest me. I mean, and I think you already know, I am poor programmer

so I need to be explained.

Following my code, I put some delay after sending, It varies from 1 to 100, no effect.

I have included in the project Logging_WinSim.c but not included any call to functions in it.

By the way, Eclipse marks the file as there are errors but the build has no error.

The error comes from StreamBuffer_t which has double definition, one in stream_buffer.c and another in

FreeRTOS_Stream_Buffer.h. And I have no idea how to fix this duplication.

Thanks very much. Looking forward to your reply.

Best Regards

bool RDPServer::ScanStripes()

{

int i;

int dirtyCounter = 0;

bool dirtyStripes[RDP_STRIPES];

for (i=0 ; i<RDP_STRIPES ; i++)

{

if (Graphics::RDPUpdateStripe(i*RDP_STRIPE_HEIGHT, RDP_STRIPE_HEIGHT ,

rdpFrame, firstScan))

{

dirtyStripes[i] = true;

dirtyCounter++;

}

else dirtyStripes[i] = false;

}

// first send the number of stripes modified

if (0!=dirtyCounter)

{

//((Socket_t)pSockDat->socket)->xSendBlockTime = 0;

BaseType_t t = FreeRTOS_send((Socket_t)pSockDat->socket, &dirtyCounter , sizeof(dirtyCounter) , 0);

if (t < 0)

{

return false;

}

for (i=0 ; i<RDP_STRIPES ; i++)

{

if (dirtyStripes[i])

{

int currRow = i*RDP_STRIPE_HEIGHT;

t = FreeRTOS_send((Socket_t)pSockDat->socket, &currRow , sizeof(currRow) , 0);

//osDelay(1);

if (t < 0)

{

return false;

}

t = FreeRTOS_send((Socket_t)pSockDat->socket, &rdpFrame[currRow][0] ,RDP_STRIPE_HEIGHTLCD_TOT_COLS2 , 0);

if (t != RDP_STRIPE_HEIGHTLCD_TOT_COLS2)

{

return false;

}

//osDelay(1);

}

}

ackTx = true;

}

firstScan = false;

return true;

}

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi,

Ok, I had commented vLoggingInit( xLogToStdout, xLogToFile, pdFALSE, 0, 0 ); because of the double definition of StreamBuffer_t;

Uncomment and see what it produces.

Best

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi,

attached is the log))).

Best

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

(Attachment RTOSDemo.log is missing)

Hi,

Unfortunately I cannot attach file.

Here is the content, I made two runs.

Best

0 2 [IP-Task] prvIPTask started

IP Address: 192.168.0.251

1 27 [IP-Task] Subnet Mask: 255.255.0.0

Gateway Address: 192.168.0.1

2 27 [IP-Task] DNS Server Address: 192.168.0.5

Socket 20102 → 0.0.0.0:0 State eCLOSED->eTCP_LISTEN

3 8107 [IP-Task] Gain: Socket 20102 now has 1 / 20 child

prvSocketSetMSS: 1460 bytes for 192.168.10.161:49916

4 8107 [IP-Task] Socket 20102 → 192.168.10.161:49916 State eCLOSED->eSYN_FIRST

prvWinScaleFactor: uxRxWinSize 1 MSS 1460 Factor 0

5 8107 [IP-Task] Socket 20102 → 192.168.10.161:49916 State eSYN_FIRST->eSYN_RECEIVED

TCP: passive 20102 => 192.168.10.161:49916 set ESTAB (scaling 1)

6 8167 [IP-Task] Socket 20102 → 192.168.10.161:49916 State eSYN_RECEIVED->eESTABLISHED

TCP: RST received from 192.168.10.161:49916 for 20102

7 97268 [IP-Task] Socket 20102 → 192.168.10.161:49916 State eESTABLISHED->eCLOSED

0 1 [IP-Task] prvIPTask started

IP Address: 192.168.0.251

1 24 [IP-Task] Subnet Mask: 255.255.0.0

Gateway Address: 192.168.0.1

2 24 [IP-Task] DNS Server Address: 192.168.0.5

Socket 20102 → 0.0.0.0:0 State eCLOSED->eTCP_LISTEN

3 5744 [IP-Task] Gain: Socket 20102 now has 1 / 20 child

prvSocketSetMSS: 1460 bytes for 192.168.10.161:49928

4 5744 [IP-Task] Socket 20102 → 192.168.10.161:49928 State eCLOSED->eSYN_FIRST

prvWinScaleFactor: uxRxWinSize 1 MSS 1460 Factor 0

5 5744 [IP-Task] Socket 20102 → 192.168.10.161:49928 State eSYN_FIRST->eSYN_RECEIVED

TCP: passive 20102 => 192.168.10.161:49928 set ESTAB (scaling 1)

6 5804 [IP-Task] Socket 20102 → 192.168.10.161:49928 State eSYN_RECEIVED->eESTABLISHED

TCP: RST received from 192.168.10.161:49928 for 20102

7 37844 [IP-Task] Socket 20102 → 192.168.10.161:49928 State eESTABLISHED->eCLOSED

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hello ActoryOu,

sorry for disturbing.

I have tried to watch the communication with WireShark.

It happens that it sends chunks of 1460 bytes so could be a reason of slowness.

Where is it possible to enlarge the amount of bytes trasmitted?

Best

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi,

another update.

ipconfigTCP_TX_BUFFER_LENGTH is now 32768 and there is an improving.

Still not so frequent as a real micro with FreeRTOS.

About ipconfigNETWORK_MTU I left 1500U.

So I am looking if I can increment the frequency of transmission.

Best.

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi CHING-HSIN Lee,

Now it seems working, I still have a problem with StreamBuffer_t that is defined in FreeRTOS_Stream_Buffer.h

and in Stream_Buffer.c . This show me and error in eclipse but the project compiles.

I do not know how to resolve this situation.

And last remains the problem of speed. Using WireShark I see that the same packet is trasmitted 2 times, that’s why

it is slow.

Do you have any suggestion. Looking forward your reply.

Best Regards

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

This email may contain confidential and/or private information.

Hi @Fortunato,
Could you share the wireshark log?
Let’s find the root cause of re-transmission.

Hi Fortunato,

stream_buffer.c declare StreamBuffer_t in .c file scope only. This file doesn’t include FreeRTOS_Stream_Buffer.h. Can you share the build log or other information about the problem?

As to the problem of speed, I am also inviting other members to join the discussion.

Yes, sure

I wonder how I can attach file. I am new User

Yes,

Logging_WinSim.c includes FreeRTOS_Stream_Buffer.h where it is declared StreamBuffer_t.

and says xLogStreamBuffer->LENGTH could not be resolved. But it is not a compiler output,

it’s a message in eclipse IDE.

Best

Fortunato Marrelli
HTA s.r.l. - R&D - Software Engineer

Here two records captured with Wireshark

No. Time Source Destination Protocol Length Info
1481 56.441023 192.168.0.251 192.168.10.161 TCP 1514 20102 → 51050 [PSH, ACK] Seq=4389 Ack=17 Win=2920 Len=1460

Frame 1481: 1514 bytes on wire (12112 bits), 1514 bytes captured (12112 bits) on interface \Device\NPF_{DB672B26-423F-45AD-9793-75019C0E78AA}, id 0
Ethernet II, Src: Intel_11:11:41 (00:11:11:11:11:41), Dst: PcsCompu_89:a5:01 (08:00:27:89:a5:01)
Internet Protocol Version 4, Src: 192.168.0.251, Dst: 192.168.10.161
Transmission Control Protocol, Src Port: 20102, Dst Port: 51050, Seq: 4389, Ack: 17, Len: 1460
Data (1460 bytes)

No. Time Source Destination Protocol Length Info
1482 56.441027 192.168.0.251 192.168.10.161 TCP 1514 [TCP Retransmission] 20102 → 51050 [PSH, ACK] Seq=4389 Ack=17 Win=2920 Len=1460

Frame 1482: 1514 bytes on wire (12112 bits), 1514 bytes captured (12112 bits) on interface \Device\NPF_{DB672B26-423F-45AD-9793-75019C0E78AA}, id 0
Ethernet II, Src: Intel_11:11:41 (00:11:11:11:11:41), Dst: PcsCompu_89:a5:01 (08:00:27:89:a5:01)
Internet Protocol Version 4, Src: 192.168.0.251, Dst: 192.168.10.161
Transmission Control Protocol, Src Port: 20102, Dst Port: 51050, Seq: 4389, Ack: 17, Len: 1460