我有一个文件“myFile.gcode”,其中包含一些 G 代码命令。就目前而言,Universal Gcode Sender 允许用户上传要执行的文件。但是,我希望程序启动后立即运行“myFile.gcode”,而不是我必须上传它。
开箱即用的 .jar 文件是否可行?
.jar 可在 https://winder.github.io/ugs_website/
如果不是我有以下想法,
综上所述,这可能吗?
而且,什么可以使跟踪此代码更容易?
是的,有一个运行 CLI 命令的新功能,下载最新的 Universal G-code Sender Classic 并运行以下命令:
# java -cp UniversalGcodeSender.jar com.willwinder.ugs.cli.TerminalClient --help
这将打印可用的参数和选项:
-b,--baud <baudrate> Baud rate to connect with.
-c,--controller <controller> What type of controller firmware we are
connecting to, defaults to "GRBL". These
are the available firmwares: [GRBL, TinyG,
Testing (Delay), Smoothie Board, Testing]
-d,--daemon Starts in daemon mode providing a web
pendant UI
-dr,--driver <driver> Sets and saves the connection driver
setting. These are the available drivers:
[JSERIALCOMM, JSSC, TCP]
-f,--file <filename> Opens a file for streaming to controller
and will exit upon completion.
-h,--help Prints the help information.
-ho,--home If a homing process should be done before
any gcode files are sent to the
controller.
-l,--list Lists all available ports.
-p,--port <port> Which port for the controller to connect
to. I.e /dev/ttyUSB0 (on Unix-like systems
or COM4 (on windows).
-pp,--print-progressbar Prints the progress of the file stream
-ps,--print-stream Prints the streamed lines to console
-r,--reset-alarm Resets any alarm
-v,--version Prints the software version.
-w,--workspace <dir> Sets and saves the workspace directory
setting
可以使用以下命令发送文件:
# java -cp UniversalGcodeSender.jar com.willwinder.ugs.cli.TerminalClient --controller GRBL --port /dev/ttyUSB0 --baud 115200 --print-progressbar --file test.gcode
Connected to "Grbl 0.9z" on baud 115200
Running file "test.gcode"
test.gcode 52% │██████████████████████▉ │ 55/105 (0:00:06 / 0:00:05)
通过修改源代码重新编译应用程序,可以在Universal Gcode Sender启动时自动运行G代码文件。
为此,您需要找到负责启动应用程序的主类,并修改它以包含一个在启动时加载和执行 G 代码文件的方法。
使跟踪代码更容易的一种方法是使用 Java 开发环境,例如 Eclipse 或 IntelliJ IDEA,其中包括强大的代码分析和调试工具。这些工具可以帮助您识别主类并更轻松地浏览应用程序代码。
另一种选择是使用Java反编译器,例如JD-GUI,它可以通过将.jar文件反编译成Java源代码来帮助您理解代码的结构。但是,请记住,反编译的代码可能与原始源代码不完全相同,并且可能并不总是很容易理解。
最终,修改源代码并重新编译应用程序将使您能够最大程度地控制 Universal Gcode Sender 的行为。但是,也可以使用脚本或其他外部工具自动执行文件上传过程,具体取决于您的具体需求。