Search found 72 matches

by Ksawery
Thu Mar 26, 2020 2:38 pm
Forum: C++ Development
Topic: Error when closing application.
Replies: 2
Views: 45

Re: Error when closing application.

Ok, I've found the problem, apologies for the long post, but it had me confused for a while. The memory location I was referring to in: mbMaster->mb_mapping->tab_input_registers[11] was not created correctly, and hence the pointer errors, coming from the external Modbus library. I'm not sure why the...
by Ksawery
Thu Mar 26, 2020 2:15 pm
Forum: C++ Development
Topic: Error when closing application.
Replies: 2
Views: 45

Re: Error when closing application.

Upon further investigation, it seems that these function calls - in the Thread loop - are causing the error when closing the app for some reason: if (ct != -1) { wxCriticalSectionLocker enter(mbMaster->mb_guard); mbMaster->mb_mapping->tab_input_registers[11] = modbus_read_input_bits(ctx, 10001, MB_N...
by Ksawery
Thu Mar 26, 2020 2:05 pm
Forum: C++ Development
Topic: Error when closing application.
Replies: 2
Views: 45

Error when closing application.

Hello, I'm writing a new mulithreaded application in wxWidgets, and I'm encountering a pointer/malloc error that I can't quite figure out. I'm not sure if the problem lies in my wxWidgets code, or the external library that I'm using. On starting my wxWidgets application, I create an additional threa...
by Ksawery
Sat Oct 19, 2019 2:40 pm
Forum: C++ Development
Topic: Delete thread with blocking function
Replies: 14
Views: 712

Re: Delete thread with blocking function

I managed to find (what I hope is) a good solution to the problem, by following these recommendations: https://github.com/stephane/libmodbus/issues/452 I made the TCP/IP socket non-blocking, using the following function: fcntl(socket, F_SETFL, fcntl(socket, F_GETFL, 0) | O_NONBLOCK); This effectivel...
by Ksawery
Fri Oct 18, 2019 5:34 pm
Forum: C++ Development
Topic: Delete thread with blocking function
Replies: 14
Views: 712

Re: Delete thread with blocking function

cough...cough... it's definitely not linux What do you mean, this is under Linux Mint, Eclipse IDE :D if your lib has internal threads and has not explicit functions kinda stop_lib, terminate... you must not try to stop something inside it. I don't think the library provides any way to interact wit...
by Ksawery
Fri Oct 18, 2019 1:57 pm
Forum: C++ Development
Topic: Delete thread with blocking function
Replies: 14
Views: 712

Re: Delete thread with blocking function

Here are the threads running in the application: Temporary breakpoint 1, main (argc=1, argv=0x7fffffffddc8) at ../cPomiarWiazki.cpp:3 3 wxIMPLEMENT_APP(cPomiarWiazki); [New Thread 0x7fffeb904700 (LWP 3993)] [New Thread 0x7fffeb103700 (LWP 3994)] [New Thread 0x7fffea3f1700 (LWP 3996)] [New Thread 0x7...
by Ksawery
Fri Oct 18, 2019 1:41 pm
Forum: C++ Development
Topic: Delete thread with blocking function
Replies: 14
Views: 712

Re: Delete thread with blocking function

I still get the following message, despite using Kill(): 15:41:27: Debug: 1 threads were not terminated by the application. So I guess I can't do anything until the blocking function returns? Im undertand though, that the thread is terminated, and the heap resources are freed anyway, when the app cl...
by Ksawery
Fri Oct 18, 2019 1:13 pm
Forum: C++ Development
Topic: Delete thread with blocking function
Replies: 14
Views: 712

Re: Delete thread with blocking function

I use the following code to terminate the thread: //Delete TCP/IP thread { wxCriticalSectionLocker enter(mbThreadCS); if (mbThreadTCP) { if (mbThreadTCP->Kill() != wxTHREAD_NO_ERROR) wxLogError("Can't delete the thread!"); } } while (1) { { wxCriticalSectionLocker enter(mbThreadCS); if (!mbThreadTCP...
by Ksawery
Fri Oct 18, 2019 12:54 pm
Forum: C++ Development
Topic: Delete thread with blocking function
Replies: 14
Views: 712

Delete thread with blocking function

I currently have a function to delete and clean up all my threads when the application is closed (i'm using 3 wxThreads). Unfortunately one of the threads uses a blocking function call for incoming TCP/IP communication. The function will not return until communication is established, so in the case ...
by Ksawery
Fri Oct 18, 2019 10:52 am
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 1398

Re: "Main thread" vs. other threads

Ah, might be problem with a non-existent pointer...
by Ksawery
Fri Oct 18, 2019 10:44 am
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 1398

Re: "Main thread" vs. other threads

I have a new issue, where my App crashes on triggering one of the events. On each itteration of my worker thread, I send events to one of the "main" windows, as well as an additional "diagnostics" window (which is tied to the same main window), under the condition that it is opened by the user: //Se...
by Ksawery
Thu Oct 17, 2019 1:43 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 1398

Re: "Main thread" vs. other threads

Sorry, turns out it was a simple error in not resetting a counter, and trying to access an invalid memory location. I will continue to test the application, hopefully it will work well now :)

Regards,
Ksawery
by Ksawery
Thu Oct 17, 2019 1:30 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 1398

Re: "Main thread" vs. other threads

The application now successfully compiles, but unfortunately crashes after 20 seconds or so, for some unknown reason. I seem to be getting different errors reported in the console each time. For example: corrupted double-linked list or (PomiarWiazki_Gateway:18974): GLib-GObject-[1;35mCRITICAL[0m **:...
by Ksawery
Thu Oct 17, 2019 12:10 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 1398

Re: "Main thread" vs. other threads

to make clean multithreading design you need blocking functions, and better blocking with timeout. do this Modbus library has any to read the data? or you are just polling modbus devices kinda to control their state or something? which lib are you using for modbus? I'm using the latest version of t...
by Ksawery
Thu Oct 17, 2019 12:06 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 1398

Re: "Main thread" vs. other threads

in simple words cMain has declared virtual method, but not implemented it. and there are no other implemented virtual methods in cMain. Thank you, this was it! I declared a virtual method that was meant to override a method in the wxThreadHelper class, but I removed all helper thread code from the ...