I just put a bit of time into getting the GCodeDriver to play nice with KFlop, and thought I'd share my solution for those trying to do the same (either with a KFlop, or another oddball/unique controller). There were just 3 small changes required to make it work a treat:
1. KFlop requires carriage returns instead of newlines after each command to register anything at all
2. The scripting command for moves (accessible from the virtual COM port) requires all axes to be present regardless of them changing or not. (There are many other ways to interact with KFlop, some of which would allow for normal GCode... but by using the virtual com port, no other applications are needed, and it much more closely resembles "normal" OpenPNP solutions).
3. KFlop doesn't return any information as to when the move is complete (again - referring only to when using the vcom port scripting) ... To get this, we need to poll the controller to check when the motion is done.
These fixes for these are really pretty minor:
1. Added a "useCRinsteadOfNewline" boolean attribute to send "\r" instead of "\n" after commands
2. Added another boolean attribute "alwaysSendAllAxes" to simply disable the removal of unmodified axes
3. Added a "POLL_FOR_COMPLETE_COMMAND" which (when filled) works with the "MOVE_TO_COMPLETE_REGEX" to poll for completion status instead of just waiting idly.
With those changes in place, the commands/setup get pretty straightforward too... for example:
CONNECT_COMMAND:
Version
DefineCS = 0 1 2 -1 -1 -1
COMMAND_CONFIRM_REGEX
^Ready*
MOVE_TO_COMMAND:
Vel0={FeedRate:%.0f}
Vel1={FeedRate:%.0f}
Vel2={FeedRate:%.0f}
MoveXYZABC {X:%.4f} {Y:%.4f} {Z:%.4f} 0 0 0
POLL_FOR_COMPLETE_COMMAND:
CheckDoneXYZABC
MOVE_TO_COMPLETE_REGEX:
^1*
I'll attach the complete GCodeDriver.java and the driver section of Machine.xml, below... but with a few notes first:
- As you can see from the move command, I don't actually control my rotation axis with the KFlop (at least not yet)... but it will work just fine if you add the extra variables
- I haven't bothered with most of the other commands just yet (as I haven't finished changing all of my hardware), but I have tested setting/clearing bits, and that works just fine too
- The max feedrate set in the UI will actually be in units/second (i.e. mm/second) instead of the units/minute that the UI says it is... This would be an easy fix to scale, but I wanted to limit changes as much as possible, and I thought it was livable.
If there is call for it, I can send a pull request once I'm a bit more up to speed (I have a fair bit of coding experience, but I'm new to Java/Eclipse/OpenPNP coding, and have very limited experience with git)... Alternatively - feel free to incorporate whatever you like without waiting on me (again - really pretty limited changes, and it's based off the code pulled from GitHub yesterday). I just knew that if I didn't share this now, there would be a moderate-to-high possibility that something shiny would distract me, and it wouldn't get done for months (if at all).
Finally - as it's my first time posting around here, I just wanted to say a huge thanks to Jason and everyone else that has contributed so much to this project... I've been checking in on things occasionally for a year or two (without the time to really dig into things until now), and while it was hugely powerful and exciting even back then... the pace of improvement is just awesome!!! Keep up the great work!
Cheers,
Brad