Skip to content

Commit

Permalink
Getting close
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchBradley committed Feb 14, 2022
1 parent c8cdb9b commit 27c4494
Show file tree
Hide file tree
Showing 24 changed files with 333 additions and 275 deletions.
55 changes: 26 additions & 29 deletions build-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def buildFs(pioEnv, verbose=verbose, extraArgs=None):

sharedPath = 'install_scripts'

def copyToZip(zipObj, platform, destPath, mode=0o100755):
sourcePath = os.path.join(sharedPath, platform, destPath)
def copyToZip(zipObj, platform, fileName, destPath, mode=0o100755):
sourcePath = os.path.join(sharedPath, platform, fileName)
with open(sourcePath, 'r') as f:
bytes = f.read()
info = ZipInfo.from_file(sourcePath, destPath)
info = ZipInfo.from_file(sourcePath, os.path.join(destPath, fileName))
info.external_attr = mode << 16
zipObj.writestr(info, bytes)

Expand All @@ -74,49 +74,46 @@ def copyToZip(zipObj, platform, destPath, mode=0o100755):
if buildEnv(envName, verbose=verbose) != 0:
sys.exit(1)

for platform in ['win64', 'macos', 'linux-amd64', 'linux-python3']:
for platform in ['win64', 'macos', 'linux']:
print("Creating zip file for ", platform)
terseOSName = {
'win64': 'win',
'linux-amd64': 'linux',
'linux-python3': 'linux',
'linux': 'linux',
'macos': 'macos'
}
scriptExtension = {
'win64': '.bat',
'linux-amd64': '.sh',
'linux-python3': '.sh',
'linux': '.sh',
'macos': '.sh'
}
exeExtension = {
'win64': '.exe',
'linux-amd64': '',
'linux-python3': '',
'linux': '',
'macos': ''
}
withEsptoolBinary = {
'win64': True,
'linux-amd64': True,
'linux-python3': False,
'linux': False,
'macos': True
}

zipFileName = os.path.join(relPath, 'fluidnc-' + tag + '-' + platform + '.zip')
zipDirName = os.path.join('fluidnc-' + tag + '-' + platform)
zipFileName = os.path.join(relPath, zipDirName + '.zip')

with ZipFile(zipFileName, 'w') as zipObj:
name = 'HOWTO-INSTALL.txt'
zipObj.write(os.path.join(sharedPath, platform, name), name)
zipObj.write(os.path.join(sharedPath, platform, name), os.path.join(zipDirName, name))

pioPath = os.path.join('.pio', 'build')

# Put bootloader binaries in the archive
tools = os.path.join(os.path.expanduser('~'),'.platformio','packages','framework-arduinoespressif32','tools')
bootloader = 'bootloader_dio_80m.bin'
zipObj.write(os.path.join(tools, 'sdk', 'bin', bootloader), os.path.join('common', bootloader))
zipObj.write(os.path.join(tools, 'sdk', 'bin', bootloader), os.path.join(zipDirName, 'common', bootloader))
bootapp = 'boot_app0.bin';
zipObj.write(os.path.join(tools, "partitions", bootapp), os.path.join('common', bootapp))
secFuses = 'SecurityFusesOK.bin';
zipObj.write(os.path.join(sharedPath, secFuses), os.path.join('common', secFuses))
zipObj.write(os.path.join(tools, "partitions", bootapp), os.path.join(zipDirName, 'common', bootapp))
for secFuses in ['SecurityFusesOK.bin', 'SecurityFusesOK0.bin']:
zipObj.write(os.path.join(sharedPath, secFuses), os.path.join(zipDirName, 'common', secFuses))

# Put FluidNC binaries, partition maps, and installers in the archive
for envName in ['wifi','bt']:
Expand All @@ -125,29 +122,29 @@ def copyToZip(zipObj, platform, destPath, mode=0o100755):
# bt does not need a spiffs.bin because there is no use for index.html.gz
if envName == 'wifi':
name = 'spiffs.bin'
zipObj.write(os.path.join(pioPath, envName, name), os.path.join(envName, name))
zipObj.write(os.path.join(pioPath, envName, name), os.path.join(zipDirName, envName, name))
name = 'index.html.gz'
zipObj.write(os.path.join('FluidNC', 'data', name), os.path.join(envName, name))
zipObj.write(os.path.join('FluidNC', 'data', name), os.path.join(zipDirName, envName, name))

objPath = os.path.join(pioPath, envName)
for obj in ['firmware.bin','partitions.bin']:
zipObj.write(os.path.join(objPath, obj), os.path.join(envName, obj))
zipObj.write(os.path.join(objPath, obj), os.path.join(zipDirName, envName, obj))

# E.g. macos/install-wifi.sh -> install-wifi.sh
copyToZip(zipObj, platform, 'install-' + envName + scriptExtension[platform])
copyToZip(zipObj, platform, 'install-' + envName + scriptExtension[platform], zipDirName)

for script in ['install-fs', 'fluidterm', 'checksecurity', 'tools', ]:
for script in ['install-fs', 'fluidterm', 'checksecurity', 'erase', 'tools']:
# E.g. macos/fluidterm.sh -> fluidterm.sh
copyToZip(zipObj, platform, script + scriptExtension[platform])
copyToZip(zipObj, platform, script + scriptExtension[platform], zipDirName)

# Put the fluidterm code in the archive
for obj in ['fluidterm.py', 'README.md']:
fn = os.path.join('fluidterm', obj)
zipObj.write(fn, fn)
zipObj.write(fn, os.path.join(zipDirName, fn))

if platform == 'win64':
obj = 'fluidterm' + exeExtension[platform]
zipObj.write(os.path.join('fluidterm', obj), os.path.join(platform, obj))
zipObj.write(os.path.join('fluidterm', obj), os.path.join(zipDirName, platform, obj))

EsptoolVersion = 'v3.1'

Expand All @@ -161,7 +158,7 @@ def copyToZip(zipObj, platform, destPath, mode=0o100755):
EspRepo = 'https://github.com/espressif/esptool/archive/refs/tags/'
EspDir = EsptoolVersion

zipObj.write(os.path.join(sharedPath, name), os.path.join(platform,
zipObj.write(os.path.join(sharedPath, name), os.path.join(zipDirName, platform,
name.replace('.txt', '-' + EsptoolVersion + '.txt')))

# Download and unzip from ESP repo
Expand All @@ -175,11 +172,11 @@ def copyToZip(zipObj, platform, destPath, mode=0o100755):
Binary += exeExtension[platform]
sourceFileName = EspDir + '/' + Binary
with ZipFile(ZipFileName, 'r') as zipReader:
destFileName = os.path.join(platform, Binary)
destFileName = os.path.join(zipDirName, platform, Binary)
info = ZipInfo(destFileName)
info.external_attr = 0o100755 << 16
zipObj.writestr(info, zipReader.read(sourceFileName))
else:
zipObj.write(os.path.join(ZipFileName), os.path.join(platform, 'esptool-source.zip'))
zipObj.write(os.path.join(ZipFileName), os.path.join(zipDirName, platform, 'esptool-source.zip'))

sys.exit(0)
64 changes: 44 additions & 20 deletions fluidterm/fluidterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
if platform.system() == 'Darwin':
import subprocess
else:
from tkinter import *
from tkinter import filedialog
from tkinter import simpledialog
try:
from tkinter import *
from tkinter import filedialog
from tkinter import simpledialog
except:
pass

import time

import serial
Expand Down Expand Up @@ -498,6 +502,7 @@ def ask_for_port():
ports = []
if len(comports()) == 1:
return comports()[0].device

sys.stderr.write('\n--- Available ports:\n')
for n, (port, desc, hwid) in enumerate(sorted(comports()), 1):
sys.stderr.write('--- {:2}: {:20} {!r}\n'.format(n, port, desc))
Expand Down Expand Up @@ -686,8 +691,7 @@ def writer(self):
# If you restart FluidNC with $bye or the reset switch, you
# will have to trigger interactive mode manually
time.sleep(2) # Time for FluidNC to be ready for input
right_arrow = '\x1b[C'
self.serial.write(self.tx_encoder.encode(right_arrow))
self.enable_fluid_echo();

try:
while self.alive:
Expand All @@ -698,11 +702,10 @@ def writer(self):
for c in data:
if not self.alive:
break
if menu_active:
self.handle_menu_key(c)
menu_active = False
elif c == self.menu_character:
menu_active = True # next char will be for menu
if c == '\x15': # CTRL+U -> upload file with XModem
self.upload_xmodem()
elif c == '\x12': # CTRL+R -> reset FluidNC
self.reset_fluidnc()
elif c == self.exit_character:
self.stop() # exit app
break
Expand Down Expand Up @@ -885,12 +888,32 @@ def file_dialog(self, initial):
destname = self.mac_askstring(os.path.split(pathname)[1])
return (pathname, destname)
else:
window = Tk()
pathname = filedialog.askopenfilename(title="File to Upload", initialfile=initial, filetypes=[("FluidNC Config", "*.yaml *.flnc *.txt"), ("All files", "*")])
print("path",pathname)
destname = simpledialog.askstring("Uploader", "Destination Filename", initialvalue=os.path.split(pathname)[1])
window.destroy()
return (pathname, destname)
try:
window = Tk()
except:
pathname = raw_input("Local file to send: ")
destname = raw_input("File on FluidNC: ")
return (pathname, destname)
else:
pathname = filedialog.askopenfilename(title="File to Upload", initialfile=initial, filetypes=[("FluidNC Config", "*.yaml *.flnc *.txt"), ("All files", "*")])
print("path",pathname)
destname = simpledialog.askstring("Uploader", "Destination Filename", initialvalue=os.path.split(pathname)[1])
window.destroy()
return (pathname, destname)

def enable_fluid_echo(self):
right_arrow = '\x1b[C'
self.serial.write(self.tx_encoder.encode(right_arrow))

def reset_fluidnc(self):
"""Pulse the reset line for FluidNC"""
self.console.write("Resetting MCU\n")
self.serial.rts = True
self.serial.dtr = False
time.sleep(1)
self.serial.rts = False
time.sleep(1)
self.enable_fluid_echo()

def upload_xmodem(self):
"""Ask user for filename and send its contents"""
Expand Down Expand Up @@ -1053,6 +1076,7 @@ def get_help_text(self):
--- {exit:7} Send the exit character itself to remote
--- {info:7} Show info
--- {upload:7} Upload file (prompt will be shown)
--- {xmodem:7} Upload file via XMODEM (prompt will be shown)
--- {repr:7} encoding
--- {filter:7} edit filters
--- Toggles:
Expand All @@ -1076,6 +1100,7 @@ def get_help_text(self):
echo=key_description('\x05'),
info=key_description('\x09'),
upload=key_description('\x15'),
xmodem=key_description('\x18'),
repr=key_description('\x01'),
filter=key_description('\x06'),
eol=key_description('\x0c'))
Expand Down Expand Up @@ -1295,11 +1320,10 @@ def main(default_port=None, default_baudrate=115200, default_rts=None, default_d
if not args.quiet:
sys.stderr.write('--- Fluidterm on {p.name} {p.baudrate},{p.bytesize},{p.parity},{p.stopbits} ---\n'.format(
p=miniterm.serial))
sys.stderr.write('--- Quit: {} | Menu: {} | Help: {} followed by {} ---\n'.format(
sys.stderr.write('--- Quit: {} | Upload: {} | Reset: {} ---\n'.format(
key_description(miniterm.exit_character),
key_description(miniterm.menu_character),
key_description(miniterm.menu_character),
key_description('H')))
key_description('\x15'),
key_description('\x12')))

miniterm.start()
try:
Expand Down
19 changes: 0 additions & 19 deletions install_scripts/linux-python3/checksecurity.sh

This file was deleted.

8 changes: 0 additions & 8 deletions install_scripts/linux-python3/fluidterm.sh

This file was deleted.

19 changes: 0 additions & 19 deletions install_scripts/linux-python3/install-bt.sh

This file was deleted.

14 changes: 0 additions & 14 deletions install_scripts/linux-python3/install-fs.sh

This file was deleted.

19 changes: 0 additions & 19 deletions install_scripts/linux-python3/install-wifi.sh

This file was deleted.

42 changes: 0 additions & 42 deletions install_scripts/linux-python3/tools.sh

This file was deleted.

Loading

0 comments on commit 27c4494

Please sign in to comment.