naueramant / go-3d-printer Goto Github PK
View Code? Open in Web Editor NEWPackage which provides control over a FDM 3D printer through a serial connection.
License: GNU General Public License v3.0
Package which provides control over a FDM 3D printer through a serial connection.
License: GNU General Public License v3.0
Please check my fork https://github.com/alexsuslov/go-3d-printer
this will allow using go-3d-printer as module
BRGD
Alex
Hi
What do u think about
type IFirmwareInformation interface {
FirmwareVersion()string
ProtocolVersion()string
MachineType()string
ExtruderCount()int
UUID()string
}
type FirmwareInformation struct {
info map[string]string
}
func ParseHead(line string, info map[string]string){
pois:=[]int{}
for _, name := range names{
poi:=strings.Index(line, name)
pois= append(pois, poi)
}
sort.Sort(sort.Reverse(sort.IntSlice(pois)))
e:=len(line)
for _,s:= range pois{
line:=line[s:e]
v:=strings.Split(line, ":")
info[v[0]]=v[1]
e=s
}
}
var names = []string{
"FIRMWARE_NAME",
"SOURCE_CODE_URL",
"PROTOCOL_VERSION",
"MACHINE_TYPE",
"EXTRUDER_COUNT",
"UUID",
}
func ParseHead(line string, info map[string]string){
pois:=[]int{}
for _, name := range names{
poi:=strings.Index(line, name)
pois= append(pois, poi)
}
sort.Sort(sort.Reverse(sort.IntSlice(pois)))
e:=len(line)
for _,s:= range pois{
line:=line[s:e]
v:=strings.Split(line, ":")
info[v[0]]=v[1]
e=s
}
}
Convert example
FIRMWARE_NAME:Marlin Ver 1.0.1 SOURCE_CODE_URL:https://github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender-3 V2 EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff
Cap:SERIAL_XON_XOFF:0
Cap:BINARY_FILE_TRANSFER:0
Cap:EEPROM:1
Cap:VOLUMETRIC:1
Cap:AUTOREPORT_TEMP:1
Cap:PROGRESS:0
Cap:PRINT_JOB:1
Cap:AUTOLEVEL:0
Cap:Z_PROBE:0
Cap:LEVELING_DATA:0
Cap:BUILD_PERCENT:0
Cap:SOFTWARE_POWER:0
Cap:TOGGLE_LIGHTS:0
Cap:CASE_LIGHT_BRIGHTNESS:0
Cap:EMERGENCY_PARSER:0
Cap:PROMPT_SUPPORT:0
Cap:AUTOREPORT_SD_STATUS:0
Cap:THERMAL_PROTECTION:1
Cap:MOTION_MODES:0
Cap:CHAMBER_TEMPERATURE:0
ok
to map
info = {map[string]string}
0 = UUID -> cede2a2f-41a2-4748-9b12-c55c62f367ff
1 = SERIAL_XON_XOFF -> 0
2 = AUTOREPORT_TEMP -> 1
3 = PROGRESS -> 0
4 = PRINT_JOB -> 1
5 = TOGGLE_LIGHTS -> 0
6 = THERMAL_PROTECTION -> 1
7 = EXTRUDER_COUNT -> 1
8 = BINARY_FILE_TRANSFER -> 0
9 = VOLUMETRIC -> 1
10 = Z_PROBE -> 0
11 = AUTOREPORT_SD_STATUS -> 0
12 = MOTION_MODES -> 0
13 = PROTOCOL_VERSION -> 1.0
14 = SOURCE_CODE_URL -> https
15 = FIRMWARE_NAME -> Marlin Ver 1.0.1
16 = EEPROM -> 1
17 = AUTOLEVEL -> 0
18 = BUILD_PERCENT -> 0
19 = EMERGENCY_PARSER -> 0
20 = MACHINE_TYPE -> Ender-3 V2
21 = LEVELING_DATA -> 0
22 = SOFTWARE_POWER -> 0
23 = CASE_LIGHT_BRIGHTNESS -> 0
24 = PROMPT_SUPPORT -> 0
25 = CHAMBER_TEMPERATURE -> 0
iMac:go-3d-printer $ ls /dev/tty.usb*
/dev/tty.usbmodem3853306E35391
iMac:go-3d-printer $ go run cmd/wifi/wifi.go
...
INFO[0000] bytes Received data=2 n=1
INFO[0000] bytes Received data=0 n=1
INFO[0000] bytes Received data=2 n=1
INFO[0000] bytes Received data=1 n=1
INFO[0000] bytes Received data=- n=1
INFO[0000] bytes Received data=0 n=1
INFO[0000] bytes Received data=1 n=1
INFO[0000] bytes Received data=- n=1
INFO[0000] bytes Received data=2 n=1
INFO[0000] bytes Received data=1 n=1
INFO[0000] bytes Received data="\n" n=1
INFO[0000] bytes Received data=o n=1
INFO[0000] bytes Received data=k n=1
INFO[0000] bytes Received data="\n" n=1
FATA[0001] Timed outed trying to detect firmware: Printer did not respond after 1 second(s)
exit status 1
In my mind we have to collect bytes until the result appears "ok\n"
check printer response
Begin file list
.Spotlight-V100.DIR
._KKP3_kruk.gcode
PidCalibration.gcode
KKP3_kruk.gcode
End file list
ok
no size after name
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.