Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Moderators: TomKerekes, dynomotion

Post Reply
jossmilde
Posts: 1
Joined: Thu Dec 27, 2018 1:36 pm

Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Post by jossmilde » Thu Dec 27, 2018 2:34 pm

Hello,

When I hover over the tool field in KMotionCNC the application crashes.
I recently updated KMotionCNC from 4.34a to 4.35a.
I copied all settings including my old tool table into C:\KMotion435a\KMotion\Data.
I had a few comments in my tool old tool table, after removing them everything works fine.
I have attached my old and new tool table for reference, maybe someone can find out what's wrong with the old table.

Jos
Attachments
ToolTable435a.txt
(4.18 KiB) Downloaded 69 times
ToolTable434a.txt
(4.85 KiB) Downloaded 76 times

User avatar
TomKerekes
Posts: 982
Joined: Mon Dec 04, 2017 1:49 am

Re: Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Post by TomKerekes » Thu Dec 27, 2018 8:40 pm

Hi Jos,

Thanks for reporting the bug. The issue has to do with the Tool Tip message being greater than 80 characters. With your comment and offsets the Tool Tip is:

Tool 1 17mm schrobfrees Slot:1 ID:1 Length:30.1660 Diam:17.2500 X offset:-107.1700 Y offset:291.8400

Here is a Patch for Version 4.35a that should solve the problem. Copy it to your KMotion\Release directory.
Regards,

Tom Kerekes
Dynomotion, Inc.

larryjamessmith
Posts: 11
Joined: Mon Dec 23, 2019 9:18 pm

Re: Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Post by larryjamessmith » Thu Jan 09, 2020 8:44 pm

I just submitted a bug report on similar behavior. As a fairly new member I did not know where to send this report and sent it as a message to Administration.
I will try the new release, but I do not believe it solves the root issue which I am convinced has to do with the overall length of the tool record, not the length of any individual field such as Message.

Here is what I wrote:
Gentlemen,
First let me say that I have used and enjoyed your products for a long time but have just recently been doing intensive work to configure my mill including a number of my own C programs. I discovered an issue which creates problems which crash your KMotion screen and wreaks havoc with any C programs which open and read the active Tools.tbl file. Stability is dependent on the content of the .tbl file. This can be demonstrated by adding content via your Edit feature to a tool which results in a long record for that tool in the file. Once the tool edit has been saved, simply hovering the mouse over the tool selection control on the screen will result in an hour-glass, followed by KMotionCNC crashing. I confirmed this on a factory-fresh version of the software.

Within a C program written to read from the .tbl file this issue can be seen as a read buffer over-run within the fscanf function which causes spurious problems, overwriting variables which happen to follow the read buffer setup by fscanf. I discovered this after a lot of head-scratching and cussing. I found that if any tool record has a length exceeding 128 bytes this happens. Depending on the file content it can be innocuous or it can be disastrous. Apparently the C-compiler you use or the library it draws upon limits BUF_SIZE to 128 bytes and I found no way to increase this. Most of the records in the .tbl file exceed 128 bytes.

To demonstrate you can try these two tool specifications, one which the KMotionCNC tools selection control accepts OK, and the other which crashes the program:
SLOT ID LENGTH DIAMETER XOFFSET YOFFSET COMMENT IMAGE
OK Tool: 17 1000 1.750000 0.200000 0.000000 0.000000 "Edge Finder 0.2 inch Diameter" "EndMill-Square.wrl"
Crashes Software: 17 1000 1.750000 0.200000 0.340000 0.560000 "Edge Finder 0.2 inch Diameter" "EndMill-Square.wrl"

Once you confirm this I suggest a reasonable change would be to remove spaces padded between parameters and reduce the digits of precision to allow more room for the Message and the Image fields. Then limit the Message and Image fields as necessary to keep the count below 128 (I recommend keeping the Message field as long as possible and reduce the Image field since people can always get creative with short file names). Until some fix is made I must maintain a separate table to manage the Comment and Image information which I want to use to notify the operator when changing tools. Feel free to call me to discuss: (541)520-3365

Thank you,
Larry Smith

User avatar
TomKerekes
Posts: 982
Joined: Mon Dec 04, 2017 1:49 am

Re: Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Post by TomKerekes » Thu Jan 09, 2020 11:23 pm

Hi Larry,

You are correct the KFLOP Disk/Console IO was not designed to handle lines longer than 128 characters.

Actually I believe fgets() does use a read buffer of 1024 characters if that helps. So you should be able to read longer lines but not write them. I tried this:

Code: Select all

#include "KMotionDef.h"

main()
{
	FILE *f;
	char s[1001];
	int i;
	
	f=fopen("c:\\Temp\\KFlopData.txt","rt");
	if (!f)
	{
		printf("Unable to open file\n");
		return;
	}
	
	// read a line
	fgets(s, 1000, f);
	fclose(f);
	
	i=0;
	while (s[i])  // count and print each character read
	{
		printf("i=%d c = %c\n", i, s[i]);
		i++;
	}
}
I believer the KMotionCNC Tool Tip crash issue with very long names was fixed in Version 4.35b.

What exactly are you trying to do? We might be able to find an alternate approach.
Regards,

Tom Kerekes
Dynomotion, Inc.

larryjamessmith
Posts: 11
Joined: Mon Dec 23, 2019 9:18 pm

Re: Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Post by larryjamessmith » Fri Jan 10, 2020 12:27 am

Tom,
Thank you for the prompt response. I am impressed!
What I am trying to do is to read all information about the current tool and present it to the operator in a modal Windows message box after the machine moves into position for a manual tool change to be performed. I could not see where the Message or Image fields were available in any calls available (like GetToolLength). So, I wrote a routine which opens the tool file, looks for a match on the tool ID, and does a formatted read of all the fields, reading the numeric info directly into integer and double variables as appropriate and parsing the text information into the Message and Image strings.

Thanks again,
Larry

User avatar
TomKerekes
Posts: 982
Joined: Mon Dec 04, 2017 1:49 am

Re: Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Post by TomKerekes » Fri Jan 10, 2020 6:39 pm

Hi Larry,

Does that workaround work for you?
Regards,

Tom Kerekes
Dynomotion, Inc.

larryjamessmith
Posts: 11
Joined: Mon Dec 23, 2019 9:18 pm

Re: Importing tooltable in KMotionCNC 4.35a causes a crash of the application

Post by larryjamessmith » Fri Jan 10, 2020 7:02 pm

Tom,
I got it working great with fgets(). I just had to add code to break the return string into the fields needed and I am using the tool table directly without having to maintain a new table as I feared. Thanks again for the tip! My toolchange routine now works just like I want it to:

1) Save current position and spindle state.
2) Move up to clear any work and move to location above tool change location.
3) Turn on light and display message for operator to remove current tool. Wait for operator OK.
4) Based on length of new tool, move to 1.0 inch above table.
5) Display message to operator with full description of tool to install. Wait for operator to install tool using 1 inch height gauge.
6) Lights off, move up and return to saved location. Resume spindle state.

Thanks again,
Larry

Post Reply