Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Forte stops running on Raspberry Pi after a certain time(Is there a setting on the RPi I am missing?)
Forte stops running on Raspberry Pi after a certain time [message #1772713] Thu, 14 September 2017 08:49 Go to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Hello again.

I have my RPi set up so that forte is started automatically in rc.local.
However, after some time (usually a few hours, up to a bit less than a day), the process just stops. It does not appear that the RPi has rebooted or anything, because there is no forte process running when this happens.

I have tested the exact same application (boot files) on a Win32 version of FORTE on my Windows PC and it runs without interruption (I tested it for 4 days).

So it appears to be a problem with either the Posix build or the RPi. Has anyone encountered this behaviour before? Maybe I am missing an important setting.

Otherwise, I would be happy for any hints on how to debug this (i.e. does forte have a logger that can be enabled)?
Re: Forte stops running on Raspberry Pi after a certain time [message #1772715 is a reply to message #1772713] Thu, 14 September 2017 09:11 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
Hi,

That's strange.

First of all, yes, forte has a logger. In CMake there's a variable called FORTE_LOGLEVEL which you can set to the level of detail you want (LOGDEBUG might be too much in some cases, but LOGINFO could be enought withou any problem).

You get the following output when starting forte:

INFO: T#01ms: FORTE is up and running
INFO: T#04ms: Using default bootfile location: forte.fboot
WARNING: T#08ms: Boot file forte.fboot could not be opened. Skipping...
INFO: T#012ms: CWin32SocketInterface: Opening TCP-Server connection at: localhost:61499


Questions:
1- Are you using some external libraries like opcua, mqtt or other with forte?
2- Are you using your own service Function Block?
3- Which version of forte are you running? (which commit did you compile?)
Re: Forte stops running on Raspberry Pi after a certain time [message #1772717 is a reply to message #1772715] Thu, 14 September 2017 09:39 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Thanks. I will activate the logger and see if I can find out anything. Does it log to a file or just the terminal?

I am using a few custom SIFBs:
- Two extensions of BFBs that save their internal data for backup purposes. I created them because of the issue though. Before, I was using BFBs that performed the same tasks.
- One SIFB that uses the RPi's hardware watchdog library, but I stopped using it because for some reason, it caused a reboot loop when starting forte in rc.local. This, too, uses was created due to the crashing issue.
- A SIFB that requests the current system time: The only line is:
SDT().setCurrentTime();
(SDT is a DATE_AND_TIME data output). The line executes for every REQ event.

I am not using any external libraries, except for my http communication layer (which itself does not use any headers that aren't used by the standard com layers).
But the http com layer works fine on the Windows system.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772720 is a reply to message #1772717] Thu, 14 September 2017 10:21 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
Logging goes to the terminal, but you could redirect it to some file to check after it crashes.

I'd recommend to put some LOGINFO in the http layer to log out- and incomming packets (specially incomming). Even though it's happening only in the RPI, it might have to do with the layer.

Take a look at:

https://www.eclipse.org/4diac/documentation/html/development/forte_codequality.html

specially the dynamic part. This could help you detect if some memory is leaking, which wuld make the RPI more vulnerable than a regular PC.

Also, scan your code with cppcheck to find possible issues. I checked and some critical problems might occur in httpparser.cpp lines 62, 72 and 99 when using sscanf without a field limiter (specially in line 99, where you parse the GET response)

Which commit of Forte are you using to compile?
Re: Forte stops running on Raspberry Pi after a certain time [message #1772723 is a reply to message #1772720] Thu, 14 September 2017 11:26 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Thanks for the hints. I will perform the scan in the next few days and see if fixing potential leak causes solves the problem.
I am currently using the official 1.8.4 release (commit: "Created 1.8.4 release") from 2017-02-01 22:18:36
Re: Forte stops running on Raspberry Pi after a certain time [message #1772733 is a reply to message #1772723] Thu, 14 September 2017 13:08 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
You could try using the develop branch of forte. That's where the latest work is being done. Many things were improved from your version
Re: Forte stops running on Raspberry Pi after a certain time [message #1772734 is a reply to message #1772733] Thu, 14 September 2017 13:33 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
I will probably switch to the development branch when I have handed in my thesis.
For now, it is important to me to have my FB library working with the official release, because I want to make it as user-friendly as possible.
But if the Cppcheck fixes don't work, I will consider it.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772758 is a reply to message #1772734] Thu, 14 September 2017 19:59 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Okay, now something strange has happened.
I added the
-fsanitize=address
and
-fsanitize=undefined]
flags to CMAKE_CXX_FLAGS.
Since then my compiler is giving me the error message:
In file C:/.../forte_thread.cpp:18:0:
c:\sysgcc\raspberry\arm-linux-gnueabihf\include\sys\wait.h:102:22: error: '__WAIT_STATUS' was not declared in this scope
 extern __pid_t wait (__WAIT_STATUS __stat_loc);

And even after removing the two flags again the message won't go away. I created a new directory and went through the whole process of setting it up for cross-compilation in CMake-GUI and the error message keeps popping up when attempting to build. Other than setting the CMAKE_CXX_FLAGS, I did not knowingly make any changes between the last successful build and the failed one.

Any idea what could be causing it?

[Updated on: Thu, 14 September 2017 20:01]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1772779 is a reply to message #1772758] Fri, 15 September 2017 07:40 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
mmmm that's strange. You changed to the develop branch for this compilation? Are you cross compiling from a linux or a windows machine?
Re: Forte stops running on Raspberry Pi after a certain time [message #1772791 is a reply to message #1772779] Fri, 15 September 2017 09:03 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
No, I'm still on the release branch. I just reinstalled the raspberry Pi cross compile toolchain and updated the sysroot. I will try uninstalling it and reinstalling it now.

I'm cross-compiling from a Windows machine.
Building the Win32 version of forte works fine. It seems like it's just either the Posix version or the Raspberry Pi's sysroot that got corrupted somehow.

Update: Completely removing the toolchain and updating the sysroot fixed the make build error.

I performed the fixes suggested by CPPCheck, but it doesn't seem to fix the issue. And using scanf without field width limits should only cause crashes for "huge input data". The received data can only have a maximum width of 1499.

I caught forte in a frozen state on the RPi this morning. It is still listed in the running processes, but it appears to be stuck in 4diac-IDE's monitoring. I have the CLIENT FB set up so that if the output qualifier is false (i.e. if it receives an HTTP 500 INTERNAL_SERVER_ERROR response), it re-initializes the CLIENT and attempts to send the request again. This is where it appears stuck. It re-initialized the CLIENT and sent a REQ event, but no CNF event has arrived. It got stuck after about 10 attempts.

Triggering the CNF event manually issues an output event, but nothing arrives at the function block that is connected to the output. I assume this means forte is completely frozen.

For now, I will see if adding a 5 s delay between re-initialization and REQ attempts. I know that sending too many requests in short succession causes an internal server error on the REST device. I will also attempt to add some more stability fixes and logging to my HTTP layer code.

[Updated on: Fri, 15 September 2017 11:35]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1772799 is a reply to message #1772791] Fri, 15 September 2017 12:17 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
Good that you found more clues.

First thing, from the little I read about the fsanitizer, it's not available for windwos or arm compilers, at least in most cases.

Second, the build error was weird, but good that you solved it.

Third, I wasn't sure about the maximum response data, but cleaning cppcheck is always good.

Fourth. Let's go to the important stuff. Let me see if I understood correctly. You have a CLIENT FB using yout http layer, and some other FBs that when you get and error (QO = 0), you re-initialize the CLIENT, and then try a REQ? Is that right?

If yes: what do you mean with re-initialize? De-initiliaze and initialize again, or just initialize again? Is always better to de-initialize first.

It looks like when you are re-initializing, it doesn't finish it and get stuck (this might explaing why you can't send a CNF event manually). When sending the REQ after reinitilizing, do you wait for INITO of CLIENT FB? This will give you a clue if it gets stuck there.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772817 is a reply to message #1772799] Fri, 15 September 2017 15:45 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Thanks for going through this with me :)

Here's the function block network.
index.php/fa/30760/0/

I think it's easiest to understand if I explain how the http layer works.
Using forte's available CIPComLayer class to receive the data is too slow, because usually, the REST server will close the connection before the data is received.
So I created a slightly modified copy of the CIPComLayer (CHttpIPComLayer) that performs all operations - opening the connection, sending data, getting the response and closing the connection from within the sendData() method.
This way it is fast enough to get the response before the peer closes the connection.

An incoming INIT+ event doesn't actually open a connection, it parses the ID and
writes the connection params to a cache, because the socket handler's methods consume the data.

Since closeConnection() is already called at the end of every sendData() call, an INIT- event effectively does nothing.

The com layer is designed in such a way that there are 4 possible outputs:
INITO+
INITO- is only possible if the ID is invalid or QI is false
CNF+ (if an HTTP OK response is received and the body contains valid data)
CNF- (if an unexpected response is received, the timeout is exceeded or the response is invalid)

I only just added the checks for invalid responses, so maybe that'll fix it.

To explain the most important parts of the function block network:
If a CNF- event is output, it loops back to the INIT+ event and then to the E_DELAY FB, which then goes back to the REQ event. This loop goes on until a CNF+ event occurs.

  • Attachment: Capture.PNG
    (Size: 39.08KB, Downloaded 321 times)
Re: Forte stops running on Raspberry Pi after a certain time [message #1772822 is a reply to message #1772817] Fri, 15 September 2017 18:00 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
I may have found a potential cause for a buffer overflow in the CHttpIPComLayer.
I forgot to reset the m_acRecvBuffer and its m_unBufFillSize at the beginning of the sendData() method.
So it only got reset if receiving the response failed. This could also explain why it worked on my Windows Laptop and not on the Raspberry Pi.
My Windows laptop communicates with a WAN connection, while the RPi is connected to the same LAN as the REST server.
The WAN requests probably failed more often, causing the buffer to be reset before it could overflow, while the LAN connection may have resulted in enough successful requests for m_unBufFillSize to grow and grow.

I will deploy the fix and see if that solves the problem.

Update: It froze after about 16 hours...
I can still initialize a connection with a CSIFB I added for debugging purposes, but I cannot request data from it.
I also have a CSV_WRITER_6 function block that freezes in the middle of writing a line.

Update2: I just saw that calling INIT- on the function block actually deletes the whole communication stack. So I guess doing so could actually fix it. I will give this a try.

Update3: De-initializing first doesn't fix it either. This time it froze after 21 hours.

[Updated on: Mon, 18 September 2017 06:59]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1772871 is a reply to message #1772822] Mon, 18 September 2017 07:44 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
Thanks for the detailed info! I went through your http layer code. If forte freezes is normally because of an inifinite loop. I think you might have a problem with this section of code:

while ((cg_unIPLayerRecvBufferSize - m_unBufFillSize) <= 0) {
#ifdef WIN32
Sleep(0);
#else
sleep(0);
#endif
}

Once the code enters this loop, I don't see how it can go out. Maybe I missed something, but you could put a DEVLOG to see when this section of code is entered. If your buffer is fulled, it won't leave this loop.

Here:

openConnection();
if (0 >= CIPComSocketHandler::sendDataOnTCP(m_nSocketID, request, pa_unSize)) {
m_eInterruptResp = e_ProcessDataSendFailed;
}

you could check first the return value of openConnection() before trying to send, and also break the while if it fails, to avoid waiting the timeout and skip the handledConnectedDataRecv().

Regarding the CSV_WRITER I'm not sure why it freezes. I see only a possible problem that you could have if one of the inputs of the FB is longer than 100 characters, but in any case it shouldn't freeze, just write a shorter string.

And as always, I recommend to put a lot of DEVLOG information, specially when the FB could fail (and its corresponding success branch), since this code is not compiled when selecting a NODEVLOG configuration

[Updated on: Mon, 18 September 2017 07:46]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1772884 is a reply to message #1772871] Mon, 18 September 2017 11:29 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Thanks for the hint. That may have been just what I needed.
The while loop in handleConnectedDataRecv() is actually residue from forte's built in ipcomlayer (on which the httpipcomlayer is based). Technically, it shouldn't be needed, because the HTTP response should never have a character width greater than 55.

But I was able to catch the class with the following corrupted buffer in debug mode:

HTTP/1.1 200 OK
Content-Type: text/plain

1858.656
e="http[192.168.10.193:7000/rest/devices/battery/M03]" forced="false"></Data></Port><Port name="QI"><Data value="TRUE" forced="false"></Data></Port><Port name="QO"><Data value="FALSE" forced="false"></Data></Port><Port name="STATUS"><Data value="" forced="false"></Data></Port><Port name="RD_1"><Data value="0" forced="false"></Data></Port><Port name="INIT"><Data value="0" time="0"></Data></Port><Port name="REQ"><Data value=


It appears to be mixed with monitoring info being sent to 4diac-IDE.

I changed the while loop to the following:
if ((cg_unIPLayerRecvBufferSize - m_unBufFillSize) <= 0) {
	// If buffer is full, clear and return
	memset(&m_acRecvBuffer[0], 0, sizeof(m_acRecvBuffer));
	m_unBufFillSize = 0;
	m_eInterruptResp = e_ProcessDataRecvFaild;
	DEVLOG_INFO("HTTP recv buffer full\n");
	return;
}


So if it enters, it clears the buffer and notifies a failure.

I also noticed some more potential issues.
The REST server neither includes a content-length in its response headers, nor does it send the data in encoded chunks. I was relying on the detection of "\r\n\r\n" to end the loop in which the response is received. I didn't take into account that a response to a GET request has an additional body.
As a result, maybe the '\0' terminator wasn't always received (although I would have assumed that the socket handler's receiveDataFromTCP() method terminates the data it receives).

I changed it so that it always waits for the peer to close the connection (so far I haven't noticed much of a performance impact). That seems to be the only way to ensure that all of the data is received.
If it works well, I will later add some code to detect if the header has a content-length field or if the data is sent in encoded chunks.

By the way, the code I am currently using is on the development branch of the project. I will merge it over to master if there are no new issues.

I have DEVLOGs in all critical places and will see if I can start forte it in a terminal that saves the output to a text file.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772886 is a reply to message #1772884] Mon, 18 September 2017 11:44 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Okay, this is really strange. Now that I set CMAKE_BUILD_TYPE to "Debug" and the log level to LOGINFO, I am getting the same forte_thread error I was getting before.
(And again, reinstalling the toolchain fixes it and lets me build with the new settings)

[Updated on: Mon, 18 September 2017 13:24]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1772894 is a reply to message #1772886] Mon, 18 September 2017 13:23 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 644
Registered: January 2014
Senior Member
receiveDataFromTCP() will not add '\0' to your string. It will not even give you a valid C-string!!! It will just give you an array of bytes that where received from the network and the return value of receiveDataFromTCP is how many bytes have been written into the array of bytes. the content of this bytes depends on the application protocol. For example the default encoding we use for publish and subscribe will have several '\0' which is in fact 0x00 as value in the byte array. If the data you are receiving is to be interpreted as string you need to do your application layer specific string handling.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772899 is a reply to message #1772894] Mon, 18 September 2017 13:49 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Yes, that makes sense.
So if I understand correctly, it should be enough to reset the buffer's position (m_unBufFillSize) to 0 if I want to reset the buffer?
The current development version of the CHttpIpComLayer does no string parsing. That's all done by the HTTP layer.

So how could the corrupted buffer occur? Does the 4diac-IDE monitoring use the same socket address to request the function block's data inputs?
Re: Forte stops running on Raspberry Pi after a certain time [message #1772909 is a reply to message #1772899] Mon, 18 September 2017 15:30 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 644
Registered: January 2014
Senior Member
Yes this should be sufficient, One reason for the corruption could be that as monitoring needs quite some space that we have some memory overrunn in the ip layer. Although this should not really happen, but who knows. You could try by monitiring only very few valus and see if this is still happening or to increase the receive buffer size cmake option.

monoitoring is using the port 61499 per default, so the same as for downloading. Furthermore in monitoring forte is the server and in your case forte is the client. So I would expect that it is a rather strange memory issue. I'm currently traveling but i could try to look on your code later this week.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772926 is a reply to message #1772909] Mon, 18 September 2017 19:32 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Okay, it froze again.
I will have to add some more log entries again.
At the end of the current log, there are 7 repetitions of
INFO: T#014761348ms: Unexpected HTTP GET response code
INFO: T#014761348ms: CBSDSocketInterface: Opening TCP-Client connection at: 192.168.10.101:7979

So it happens at some point after opening the connection. Could receiveDataFromTCP() run an infinite loop under any circumstances?

I have spammed the code with log entries and will hopefully be able to pinpoint it more precisely.

Update:
Here's the end of the new log:
INFO: T#017081859ms: Handling received HTTP response
INFO: T#017081859ms: Unexpected HTTP PUT response code
INFO: T#017081859ms: CBSDSocketInterface: Opening TCP-Client connection at: 192.168.10.101:7979
INFO: T#017081860ms: Sending request on TCP
INFO: T#017081860ms: Attempting to receive data from TCP

The last line is just before receiveDataFromTCP(), so I guess that method must somehow be causing an infinite loop when the remote server has an error (unless for some reason, closeSocket() is the culprit).
I suppose I will have to put it in a separate thread with a timeout or something.

[Updated on: Tue, 19 September 2017 07:53]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1772940 is a reply to message #1772926] Tue, 19 September 2017 08:05 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
Try to update your coude in github. It's difficult to understand what might be happening without knowing the current state of your code.

1 - Do you still get mixed message with the monitoring?
2- Do you still call the handledConnectedDataRecv() function even if opening the connection failed?
3- in this code

strncpy(request, requestCache, strlen(requestCache) + 1);
openConnection();
if (0 >= CIPComSocketHandler::sendDataOnTCP(m_nSocketID, request, pa_unSize)) {

you use strlen as size and then pa_unSize when sending. I'd recommend to keep it clean and use always the same buffer and size variables if no special change is being done in it.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772941 is a reply to message #1772940] Tue, 19 September 2017 08:24 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
You are looking at the master branch. I had been updating the development branch, since I didn't want to make too many changes on master at once before getting it fixed.
I just merged the two branches, but I will be updating development more frequently.
The strncpy() line is still left over from the old version. It should be memcpy() with a constant size. Thanks for pointing that out.

handledConnectedDataRecv() is currently only called if the connection is opened successfully and if the data is sent successfully.

I updated my logs in my previous reply at about the same time you replied.
It appears to be receiveDataFromTCP() causing the infinite loop after multiple calls when the REST server has an internal server error.

I just realized there was a bug in the new version of my code that prevented the FB from executing a CNF- event and as a result the com stack was not deleted. But it froze before that bug was introduced, so I doubt that it's the cause.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772947 is a reply to message #1772941] Tue, 19 September 2017 09:51 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
Oops! didn't see the develop branch.

Ok, I think I was missing a big thing here. receiveDataFromTCP uses recv() which is a blocking function. So if you don't receive anything, the call will block there. Forte uses select() in its own thread in a loop (a common practice when working with sockets) which has a timeout. Select returns the socket that are ready to be read. Then the it calls the FB telling it that data is ready, and then it calls receiveDataFromTCP() which won't block forever since select() said already that the input buffer was not empty.

What you could do to test quickly is to put a call to select() with the only socket you're waiting, with your specified timeout, and only if it returns the right value you would call receiveDataFromTCP(). You should also check the return value of handledConnectedDataRecv() first before calling the topLayer.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772956 is a reply to message #1772947] Tue, 19 September 2017 12:51 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Thanks so much!
That's exactly the kind of thing I was looking for. Much simpler than a separate thread!

I still have one small problem though. I added the following code to handleConnectedDataRecv()

struct timeval tv; // Timeout
tv.tv_sec = 10; 
tv.tv_usec = 10000;
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(m_nSocketID, &fdset);
if (select(1, &fdset, NULL, NULL, &tv) > 0) {
	// call receiveDataFromTCP()
}
else {
        nRetVal = -1;
	DEVLOG_INFO("No data received from TCP\n");
}


It works fine on the Win32 version of forte, but on the Posix version, the select() return value is never greater than 0.

Update:
I got it to work by passing (m_nSocketID + 1) as the first argument to select().
Thanks again! I will post an update if it is still running smoothly in the next 2 days.

[Updated on: Tue, 19 September 2017 12:59]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1772957 is a reply to message #1772956] Tue, 19 September 2017 13:02 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
You should check if the return value of select is 0 or -1. 0 would mean a timeout and if the result is -1, you could print errno to see exactly what went wrong.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772958 is a reply to message #1772957] Tue, 19 September 2017 13:17 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
Thanks for the hint
Re: Forte stops running on Raspberry Pi after a certain time [message #1772959 is a reply to message #1772958] Tue, 19 September 2017 13:38 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 644
Registered: January 2014
Senior Member
Is still hadn't time to look at your code (for which I'm sorry) but just as a side question couldn't you register your layer at fortes select loop so that you don't need to duplicate code? Maybe something to test if your forte stops the next time.
Re: Forte stops running on Raspberry Pi after a certain time [message #1772985 is a reply to message #1772959] Tue, 19 September 2017 17:54 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
No problem :)

The first iteration of the HTTP com layer actually worked in that way, using forte's standard IP com layer that the FBDK layer uses as its bottom layer.
But it turned out to have a lot of issues.
HTTP servers usually close the connection immediately after sending the response. In the HTTP standard, this is intended behaviour, while in forte, it is treated as unwanted.
As a result, the process would be interrupted (often before the response was handled), causing the function block to issue an INIT- event almost immediately after opening the connection and receiving data.
Attempts to work around the processInterrupt quickly got messy, so I decided to create my own IP layer that is based on the FORTE one.

But if the current version works and I end up adding it to FORTE after my thesis, I could create a common parent class for the two IP layers with shared code in its protected methods.


Update:
I played around with it and got it working with forte's select loop (see development branch). But I think either changing the standard CIPComLayer's private methods to protected and subclassing it or creating a common parent class would be necessary to truly reduce code duplication.
I will leave the changes in the development branch for now, since the master branch seems to be working so far.

[Updated on: Wed, 20 September 2017 06:09]

Report message to a moderator

Re: Forte stops running on Raspberry Pi after a certain time [message #1773002 is a reply to message #1772985] Wed, 20 September 2017 07:32 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 644
Registered: January 2014
Senior Member
I can perfectly understand that you would like to finish your thesis first ;-)

I may start to test your http layer as well as I'm planing to implement the PPMP for the eclipse I4.0 testbed. Maybe then I can try to harmonize a few things.
Re: Forte stops running on Raspberry Pi after a certain time [message #1773072 is a reply to message #1773002] Thu, 21 September 2017 06:27 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 65
Registered: April 2017
Member
That would be awesome! Thanks!
By the way, if you don't mind, I would like to include everyone in the 4diac forum who helped me out in the acknowledgements.

The RPi controller is still up and running, by the way...
Re: Forte stops running on Raspberry Pi after a certain time [message #1773094 is a reply to message #1773072] Thu, 21 September 2017 12:34 Go to previous message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 103
Registered: February 2016
Senior Member
Good to read that it's working! I don't mind being in the ack
Previous Topic:improvement of usability
Next Topic:Getting FORTE boot files to work on Raspberry Pi
Goto Forum:
  


Current Time: Tue Oct 16 04:23:55 GMT 2018

Powered by FUDForum. Page generated in 0.21227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top