serial communication via com port
Mar 2, 2023 11:17:04 GMT 1
Post by alexfish on Mar 2, 2023 11:17:04 GMT 1
Thanks Peter.
Here have put the bits into a GCODE SENDER(FUNCTION)
It may be be of use to others in the realm of diy cnc + 3d printers using 'grbl'
so marlin get info code M503 using the function
& the results
result of 'makerbase robin nano' v3
Have Fun
+
BR
Alex
Here have put the bits into a GCODE SENDER(FUNCTION)
It may be be of use to others in the realm of diy cnc + 3d printers using 'grbl'
so marlin get info code M503 using the function
& the results
' works with marlin on le Potato , rpi3,rpi4,vim1s
FUNCTION GSENDER(STRING PORT$,int BAUDRATE,STRING GCODE$) TYPE STRING
GCODE$=CHOP$(GCODE$)
GCODE$=REPLACE$(GCODE$," ","")
GCODE$=REPLACE$(GCODE$,"\t","")
GCODE$=REPLACE$(GCODE$,NL$,"")
GCODE$=REPLACE$(GCODE$,"\r","")
LOCAL RETS$ TYPE STRING
PRINT GCODE$
IF FILEEXISTS(PORT$) THEN
OPEN PORT$ FOR DEVICE AS myserial2
SETSERIAL myserial2 SPEED BAUDRATE
'Set 8N1 - 8-bit characters...
SETSERIAL myserial2 CMODE ~CSIZE
SETSERIAL myserial2 CMODE CS8
' ...no parity...
SETSERIAL myserial2 CMODE ~PARENB
' ...and 1 stop bit see below
SETSERIAL myserial2 CMODE ~CSTOPB
' Set if read is blocking - 0=noblock / 1=block
SETSERIAL myserial2 OTHER VMIN = 0
' Read timeout = 0.5 seconds
SETSERIAL myserial2 OTHER VTIME = 500
sender = MEMORY(LEN(GCODE$)+2)
recd = MEMORY(2048)
FOR s = 1 TO LEN(GCODE$)
POKE sender+s-1 , ASC(MID$(GCODE$,s,1))
NEXT
POKE sender+s-1, 0
POKE sender+s, ASC(NL$)
LOCAL amt TYPE unsigned int
amt = LEN(GCODE$)+2
PUTBYTE sender TO myserial2 CHUNK amt SIZE sent
SLEEP 500
GETBYTE recd FROM myserial2 CHUNK 2048 SIZE received
IF received THEN
FOR i=0 TO received
j = PEEK(recd+i)
RETS$ = RETS$ & CHR$(j)
NEXT i
FREE sender
FREE recd
CLOSE DEVICE myserial2
RETURN RETS$
ELSE
FREE sender
FREE recd
CLOSE DEVICE myserial2
RETURN "ERROR"
END IF
ELSE
PRINT PORT$ , "Not Exist"
RETURN "ERROR"
END IF
END FUNCTION
result of 'makerbase robin nano' v3
M503
echo: G21 ; Units in mm (mm)
echo:; Filament settings: Disabled
echo: M200 T0 D1.75
echo: M200 T1 D1.75
echo: M200 S0
echo:; Steps per unit:
echo: M92 X80.00 Y80.00 Z400.00 E133.00
echo:; Maximum feedrates (units/s):
echo: M203 X300.00 Y300.00 Z5.00 E25.00
echo:; Maximum Acceleration (units/s2):
echo: M201 X3000.00 Y3000.00 Z100.00 E10000.00
echo:; Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>
echo: M204 P3000.00 R3000.00 T3000.00
echo:; Advanced: B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> J<junc_dev>
echo: M205 B20000.00 S0.00 T0.00 J0.01
echo:; Home offset:
echo: M206 X0.00 Y0.00 Z0.00
echo:; Hotend offsets:
echo: M218 T1 X0.00 Y0.00 Z0.000
echo:; PID settings:
echo: M301 P22.20 I1.08 D114.00
echo: M301 P22.20 I1.08 D114.00
echo:; Power-Loss Recovery:
echo: M413 S1
echo:; Stepper driver current:
echo: M906 X800 Y800 Z800
echo: M906 T0 E800
echo: M906 T1 E800
echo:; Driver stepping mode:
echo: M569 S1 X Y Z
echo: M569 S1 T0 E
echo: M569 S1 T1 E
echo:; Tool-changing:
echo: Z2.00
ok
Have Fun
+
BR
Alex