Issue when using SendString from UART

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
RGV250
Posts: 264
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 23 times
Been thanked: 30 times

Issue when using SendString from UART

Post by RGV250 »

Hi,
I hope this is a simple one as an example might be difficult to provide, I have attached the FC file but it would also require the DB and a couple of PHP files to actually work.
I have been testing the example with Chipfryer for retrieving values from a DB, it does not work for me and in the process of tracking the problem down have I been losing hair.
So the issue appears to be the difference in the string I am getting from the request, according to Wireshark the string is 333 bytes so I increased the Rx string to 350. When I sent the string to a serial terminal I was not getting what I expected so started to play.
Although the string can be 333 characters it appears there is a limit of 255 to what it can send. If I send a string of 255 I get what I expected (although not what I want). If I increase it to 256 I get nothing and if I increase it to 257 I get the first character of the string and so on.

This is the message I am expecting.

HTTP/1.1 200 OK\r\n
X-Powered-By: PHP/5.5.10\r\n
Content-type: text/html\r\n
Transfer-Encoding: Chunked\r\n
Date: Mon, 04 Dec 2023 11:39:39 GMT\r\n
Server: Abyss/2.16.9.1-X1-Win32 AbyssLib/2.16.9.1\r\n
\r\n
[HTTP response 1/1]
[Time since request: 0.250211000 seconds]
[Request in frame: 10]
[Request URI: http://192.168.0.15/request_sensor_a.php?Sensor=FC1]
File Data: 147 bytes
Line-based text data: text/html (13 lines)
88\r\n
<!DOCTYPE HTML>\r\n
<html lang="en">\r\n
<head>\r\n
<meta charset="UTF-8">\r\n
<title>Connect db</title>\r\n
</head>\r\n
<body>\r\n
\r\n
</body>\r\n
</html>FC1=432\r\n
0\r\n
\r\n

This is what I get on my serial terminal at 255.

HTTP/1.1 200 OK
X-Powered-By: PHP/5.5.10
Content-type: text/html
Transfer-Encoding: Chunked
Date: Mon, 04 Dec 2023 18:48:51 GMT
Server: Abyss/2.16.9.1-X1-Win32 AbyssLib/2.16.9.1

88
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">

Length_RX String = 255

When I change the string length to 256. Nothing yet the string shows it is 256.


Length_RX String = 256

If I then change it to 257 the same thing happens except it now prints "H" which is the first character of the message string???


H

Length_RX String = 257

And at 333.

HTTP/1.1 200 OK
X-Powered-By: PHP/5.5.10
Content-type: text/html
Transfer-

Length_RX String = 333
Request_my_db_2A.fcfx
(35.09 KiB) Downloaded 246 times

mnfisher
Valued Contributor
Posts: 953
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Issue when using SendString from UART

Post by mnfisher »

Is the length a byte? This would limit it to 0..255.

RGV250
Posts: 264
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 23 times
Been thanked: 30 times

Re: Issue when using SendString from UART

Post by RGV250 »

Is the length a byte? This would limit it to 0..255.
Hi,
FC allows me to create a string with a length of 350, the program shows the captured length of the incoming string is 333 so it seems that there is an issue with SendString with strings longer than 255 which is out of my control.

Bob

mnfisher
Valued Contributor
Posts: 953
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Issue when using SendString from UART

Post by mnfisher »

It is in the UART component...

Code: Select all

void FCD_05481_cal_uart__SendString(MX_CHAR *FCL_DATA, MX_UINT16 FCLsz_DATA)
{
  //Local variable definitions
  MX_UINT8 FCL_IDX;    // This will limit the size....
  MX_UINT8 FCL_LEN;

  // .Len = Length$ (.Data)
  // .Idx = 0
  FCL_LEN = FCI_GETLENGTH(FCL_DATA, FCLsz_DATA);
  FCL_IDX = 0;
Though strings can indeed be larger than this...

RGV250
Posts: 264
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 23 times
Been thanked: 30 times

Re: Issue when using SendString from UART

Post by RGV250 »

Thanks for confirming I was not going mad.
Is that something us mere mortals can see or do you need a professional licence to see it.

Bob

mnfisher
Valued Contributor
Posts: 953
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Issue when using SendString from UART

Post by mnfisher »

Yes - if you look in the wiki most of the components have the source code - but I just looked in the directory for the .c file and checked the code there.

It's easy to replicate the function of SendString to cope with long strings - here I'm relying on the \0 character at the end of the string (I assumed that Length$ might be limited to 255 but didn't check...)
SendString.fcm
(1.11 KiB) Downloaded 256 times
Martin

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: Issue when using SendString from UART

Post by BenR »

Hello,

I've been in and changed the variables in the CAL UART and the RS232 components from bytes to UINT to allow more values to be sent and received. Should now be available via the library updates.

Let me know if there are any more outstanding limits like this in place.

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 284 times
Been thanked: 412 times

Re: Issue when using SendString from UART

Post by chipfryer27 »

Hi Ben / Martin

Thanks for that.

Regards

RGV250
Posts: 264
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 23 times
Been thanked: 30 times

Re: Issue when using SendString from UART

Post by RGV250 »

Hi Ben,
That works now and I get the string I was expecting, the code is still not finding the string I am searching for (which I can see in the Rx_String) so I am wondering if the 8 bit circular buffer has a 256 byte limit as well?

Bob

Post Reply