Giter Club home page Giter Club logo

go-3d-printer's People

Contributors

naueramant avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

3dzero

go-3d-printer's Issues

IFirmwareInformation

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
}

My parse functions

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

Printer did not respond after 1 second(s)

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"

ListFiles

try ListFiles()
but nothing returned

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.