Skip to content

Commit d85e7b0

Browse files
committed
reinforce tower
1 parent 02e2338 commit d85e7b0

File tree

8 files changed

+81
-35
lines changed

8 files changed

+81
-35
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ endif
88
FLAGS = -ldflags="-w -s $(VERSION)"
99
CMD = go build -trimpath $(FLAGS)
1010
SRC = $(shell ls *.go | grep -v _test.go)
11+
EXT_FILES = README.md README.zh-cn.md LICENSE
1112

1213
.PHONY: all clean dep darwin-arm64 darwin-amd64 linux-amd64 linux-arm7 linux-arm6 win64 win32
1314

@@ -35,12 +36,16 @@ win32: $(SRC)
3536
dep: # Get the dependencies
3637
go mod download
3738

38-
all: dep darwin-arm64 darwin-amd64 linux-amd64 linux-arm7 linux-arm6 win64 win32
39+
all: dep darwin-arm64 win64 win32 darwin-amd64 linux-amd64 linux-arm7 linux-arm6
3940
@true
4041

4142
all-zip: all
42-
for p in darwin-arm64 darwin-amd64 linux-amd64 linux-arm7 linux-arm6 win64.exe win32.exe; do \
43-
zip -j $(DIST)$(NAME)-$$p.zip $(DIST)$(NAME)-$$p README.md README.zh-cn.md LICENSE; \
43+
for p in darwin-arm64 win64.exe win32.exe darwin-amd64 linux-amd64 linux-arm7 linux-arm6; do \
44+
if [ "$$p" = "win64.exe" -o "$$p" = "win32.exe" ]; then \
45+
zip -j $(DIST)$(NAME)-$$p.zip $(DIST)$(NAME)-$$p $(EXT_FILES) *.bat; \
46+
else \
47+
zip -j $(DIST)$(NAME)-$$p.zip $(DIST)$(NAME)-$$p $(EXT_FILES); \
48+
fi \
4449
done
4550

4651
clean:

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
A command-line tool for send the gcode file to Snapmaker Printers via WiFi connection.
55

66
## Features:
7-
- Support Snapmaker 2 A150/250/350, J1, Artisan
8-
- Auto discover machines (UDP broadcast)
7+
- Auto discover printers (UDP broadcast, same as Snapmaker Luban)
8+
- Upload any type of file does not depend on the head/module limit
99
- Simulated a OctoPrint server, so that it can be in any slicing software such as Cura/PrusaSlicer/SuperSlicer/OrcaSlicer send gcode to the printer
1010
- Smart pre-heat for switch tools, shutoff nozzles that are no longer in use, and other optimization features for multi-extruders.
11+
- Reinforce the prime tower to avoid it collapse for multi-filament printing
1112
- No need to click Yes button on the touch screen every time for authorization connect
13+
- Support Snapmaker 2 A150/250/350, J1, Artisan
1214
- Support for multiple platforms including win/macOS/Linux/RaspberryPi
1315

1416
## Usage:
1517
Download [sm2uploader](https://github.com/macdylan/sm2uploader/releases)
1618
- Linux/macOS: `chmod +x sm2uploader`
1719

18-
```
20+
for Windows:
21+
- locate to the sm2uploader folder, and double-click `start-octoprint.bat`
22+
- type a port number for octoprint that you wish to listen
23+
- when `Server started ...` message appears, the startup was successful, do not close the cmd window, and go to the slicer software to setup a OctoPrint printer
24+
- use `http://127.0.0.1:(PORT NUM)` as url, click the Test Connect button, all configuration will be finished if successful.
25+
26+
```bash
1927
## Discover mode
2028
$ sm2uploader /path/to/code-file1 /path/to/code-file2
2129
Discovering ...
@@ -29,17 +37,12 @@ Printer Model: Snapmaker J1
2937
Uploading file 'code-file1' [1.2 MB]...
3038
- SACP sending 100%
3139
Upload finished.
32-
33-
## Directly mode
34-
$ sm2uploader -host 192.168.1.19 /path/to/code-file1 /path/to/code-file2
35-
Printer IP: 192.168.1.19
36-
Printer Model: Snapmaker J1
37-
Uploading file 'code-file1' [1.2 MB]...
40+
Uploading file 'code-file2' [1.0 MB]...
3841
- SACP sending 100%
3942
Upload finished.
4043

41-
## use printer id
42-
$ sm2uploader -host J1V19 /path/to/code-file1 /path/to/code-file2
44+
## Use printer id
45+
$ sm2uploader -host J1V19 /path/to/code-file1
4346
Discovering ...
4447
Printer IP: 192.168.1.19
4548
Printer Model: Snapmaker J1
@@ -48,16 +51,15 @@ Uploading file 'code-file1' [1.2 MB]...
4851
Upload finished.
4952

5053
## OctoPrint server (CTRL-C to stop)
51-
$ sm2uploader -octoprint :8844 -host A350
54+
$ sm2uploader -octoprint 127.0.0.1:8844 -host A350
5255
Printer IP: 192.168.1.20
5356
Printer Model: Snapmaker 2 Model A350
5457
Starting OctoPrint server on :8844 ...
55-
Server started, now you can upload files to http://localhost:8844
58+
Server started, now you can upload files to http://127.0.0.1:8844
5659
Request GET /api/version completed in 6.334µs
5760
- HTTP sending 100.0%
5861
Upload finished: model.gcode [382.2 KB]
5962
Request POST /api/files/local completed in 951.080458ms
60-
...
6163
```
6264

6365
If UDP Discover can not work, use `sm2uploader -host 192.168.1.20 /file.gcode` to directly upload to printer.

README.zh-cn.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@ Luban 和 Cura with SnapmakerPlugin 对于新手很友好,但是我的大部
55
这个工具提供了一步上传的能力,你可以通过命令行一次上传多个 gcode/cnc/bin固件 等文件。
66

77
## 功能
8-
- 支持 Snapmaker 2 A/J1/Artisan 全系列打印机
98
- 自动发现局域网内所有的 Snapmaker 打印机(和 Luban 相同的协议,使用 UDP 广播)
109
- 模拟 OctoPrint Server,这样就可以在各种切片软件,比如 Cura/PrusaSlicer/SuperSlicer/OrcaSlicer 中向 Snapmaker 打印机发送文件
1110
- 为多挤出机提供智能预热、关闭不再使用的喷头等优化功能
11+
- 强化擦料塔,避免多材料打印时因不粘合而倒塌,例如在 PETG+PLA 混合打印时
1212
- Snapmaker 2 A-Series 第一次连接时需要授权,之后可以直接一步上传
13+
- 支持 Snapmaker 2 A/J1/Artisan 全系列打印机
1314
- 支持 macOS/Windows/Linux/RaspberryPi 多个平台
1415

1516
## 使用方法
1617
下载适用的[程序文件](https://github.com/macdylan/sm2uploader/releases)
1718
- Linux/macOS 下,可能需要赋予可执行权限 `chmod +x sm2uploader`
1819

19-
```
20+
Windows 使用方法:
21+
- 在解压目录中双击 `start-octoprint.bat` 批处理程序
22+
- 按照提示输入端口号,不输入直接回车则使用默认的 `8899` 端口
23+
- 当出现 `Server started ...` 信息时表示服务启动成功,此时不要关闭命令行窗口
24+
- 打开切片软件,设置物理打印机,输入命令行窗口中提示的 `http://127.0.0.1:端口号`,测试连接成功即可
25+
26+
```bash
2027
## 自动查找模式
2128
$ sm2uploader /path/to/code-file1 /path/to/code-file2
2229
Discovering ...
@@ -30,17 +37,12 @@ Printer Model: Snapmaker J1
3037
Uploading file 'code-file1' [1.2 MB]...
3138
- SACP sending 100%
3239
Upload finished.
33-
34-
## 指定 IP 连接模式
35-
$ sm2uploader -host 192.168.1.19 /path/to/code-file1 /path/to/code-file2
36-
Printer IP: 192.168.1.19
37-
Printer Model: Snapmaker J1
38-
Uploading file 'code-file1' [1.2 MB]...
40+
Uploading file 'code-file2' [1.0 MB]...
3941
- SACP sending 100%
4042
Upload finished.
4143

4244
## 指定打印机名字进行连接
43-
$ sm2uploader -host J1V19 /path/to/code-file1 /path/to/code-file2
45+
$ sm2uploader -host J1V19 /path/to/code-file1
4446
Discovering ...
4547
Printer IP: 192.168.1.19
4648
Printer Model: Snapmaker J1
@@ -49,16 +51,15 @@ Uploading file 'code-file1' [1.2 MB]...
4951
Upload finished.
5052

5153
## 模拟 OctoPrint (CTRL-C 终止运行)
52-
$ sm2uploader -octoprint :8844 -host A350
54+
$ sm2uploader -octoprint 127.0.0.1:8844 -host A350
5355
Printer IP: 192.168.1.20
5456
Printer Model: Snapmaker 2 Model A350
5557
Starting OctoPrint server on :8844 ...
56-
Server started, now you can upload files to http://localhost:8844
58+
Server started, now you can upload files to http://127.0.0.1:8844
5759
Request GET /api/version completed in 6.334µs
5860
- HTTP sending 100.0%
5961
Upload finished: model.gcode [382.2 KB]
6062
Request POST /api/files/local completed in 951.080458ms
61-
...
6263
```
6364

6465
打印机的 UDP 应答服务有时会挂掉,通常需要重启打印机来解决。或者你可以直接指定目标IP: `sm2uploader -host 192.168.1.20 /file.gcode`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.20
55
require (
66
github.com/gosuri/uilive v0.0.4
77
github.com/imroc/req/v3 v3.11.0
8-
github.com/macdylan/SMFix/fix v0.0.0-20230731072358-03b385d0df5a
8+
github.com/macdylan/SMFix/fix v0.0.0-20230811055700-930d31056194
99
github.com/manifoldco/promptui v0.9.0
1010
gopkg.in/yaml.v3 v3.0.1
1111
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
2121
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
2222
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2323
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
24-
github.com/macdylan/SMFix/fix v0.0.0-20230731072358-03b385d0df5a h1:yy0uQ23OaihOPf88+TWqwFPJTdCsPQTfkQBRtYqug44=
25-
github.com/macdylan/SMFix/fix v0.0.0-20230731072358-03b385d0df5a/go.mod h1:dnB1MevhW7tICqBpQ2aHpVClwLdmSBUNmfV7jpRmiWw=
24+
github.com/macdylan/SMFix/fix v0.0.0-20230811055700-930d31056194 h1:BEwsonfRa4+0lJDSFAxh59aRtB4h434mJC2rx6V+2Yk=
25+
github.com/macdylan/SMFix/fix v0.0.0-20230811055700-930d31056194/go.mod h1:dnB1MevhW7tICqBpQ2aHpVClwLdmSBUNmfV7jpRmiWw=
2626
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
2727
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
2828
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=

octoprint.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ const (
1313
)
1414

1515
var (
16-
noTrim = false
17-
noShutoff = false
18-
noPreheat = false
16+
noTrim = false
17+
noShutoff = false
18+
noPreheat = false
19+
noReinforceTower = false
1920
)
2021

2122
func LoggingMiddleware(next http.Handler) http.Handler {
@@ -64,6 +65,7 @@ func startOctoPrintServer(listenAddr string, printer *Printer) error {
6465
noTrim = strings.Contains(apiKey, "notrim")
6566
noPreheat = strings.Contains(apiKey, "nopreheat")
6667
noShutoff = strings.Contains(apiKey, "noshutoff")
68+
noReinforceTower = strings.Contains(apiKey, "noreinforcetower")
6769
msg := make([]string, 0, 3)
6870
if noTrim {
6971
msg = append(msg, "-notrim")
@@ -74,6 +76,9 @@ func startOctoPrintServer(listenAddr string, printer *Printer) error {
7476
if noShutoff {
7577
msg = append(msg, "-noshutoff")
7678
}
79+
if noReinforceTower {
80+
msg = append(msg, "-noreinforcetower")
81+
}
7782
if len(msg) > 0 {
7883
log.Printf("SMFix with args: %s", strings.Join(msg, " "))
7984
}

start-octoprint.bat

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@echo off
2+
echo Will start the sm2uploader in OctoPrint mode. press Ctrl+C to exit.
3+
4+
rem set host=-host A350
5+
set host=
6+
7+
set /p port=Enter a local port num (default is 8899)
8+
if "%port%"=="" set "port=8899"
9+
if %port% LSS 1024 (
10+
echo Port number must be greater than 1024
11+
pause
12+
exit /b 1
13+
)
14+
15+
set w64=sm2uploader-win64.exe
16+
set w32=sm2uploader-win32.exe
17+
set cmd=
18+
19+
where /q %w64% && set "cmd=%w64%"
20+
where /q %w32% && set "cmd=%w32%"
21+
22+
if "%cmd%"=="" (
23+
echo Can not find %w64% or %w32%
24+
pause
25+
exit /b 1
26+
)
27+
28+
echo %cmd% %host% -octoprint 127.0.0.1:%port%
29+
%cmd% %host% -octoprint 127.0.0.1:%port%
30+
pause

utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ func postProcess(r io.Reader) (out []byte, err error) {
6868
if !noPreheat {
6969
gcodes = fix.GcodeFixPreheat(gcodes)
7070
}
71+
if !noReinforceTower {
72+
gcodes = fix.GcodeReinforceTower(gcodes)
73+
}
7174
}
7275

7376
out = []byte(strings.Join(gcodes, "\n"))

0 commit comments

Comments
 (0)