From 24dfd8795aba54ae489b140cd7e467db8233e0d9 Mon Sep 17 00:00:00 2001 From: sago35 Date: Wed, 23 Jun 2021 20:53:56 +0900 Subject: [PATCH] sdcard: add write functionality to examples/sdcard/tinyfs --- examples/sdcard/tinyfs/console/console.go | 25 ++++++++++++++++++++++- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/examples/sdcard/tinyfs/console/console.go b/examples/sdcard/tinyfs/console/console.go index d329cde..d3e7ea5 100644 --- a/examples/sdcard/tinyfs/console/console.go +++ b/examples/sdcard/tinyfs/console/console.go @@ -35,6 +35,7 @@ var ( commands = map[string]cmdfunc{ "": noop, "dbg": dbg, + "help": help, "lsblk": lsblk, "mount": mount, "umount": umount, @@ -160,6 +161,28 @@ func runCommand(line string) { func noop(argv []string) {} +func help(argv []string) { + fmt.Printf("help\r\n") + fmt.Printf(" show help\r\n") + fmt.Printf("dbg\r\n") + fmt.Printf(" toggle debug mode\r\n") + fmt.Printf("xxd \r\n") + fmt.Printf(" hexdump the specified address\r\n") + fmt.Printf("ls \r\n") + fmt.Printf(" list information\r\n") + fmt.Printf("samples\r\n") + fmt.Printf(" write some files in the root directory\r\n") + fmt.Printf("mkdir \r\n") + fmt.Printf(" create directory\r\n") + fmt.Printf("cat \r\n") + fmt.Printf(" print the contents of file\r\n") + fmt.Printf("create \r\n") + fmt.Printf(" create file\r\n") + fmt.Printf("write \r\n") + fmt.Printf(" write to file (press CTRL-D to exit)\r\n") + fmt.Printf("rm\r\n") +} + func dbg(argv []string) { if debug { debug = false @@ -421,7 +444,7 @@ func cat(argv []string) { println("Trying to cat to " + tgt) } if tgt == "" { - println("Usage: cat ") + println("Usage: cat ") return } if debug { diff --git a/go.mod b/go.mod index d08da0f..4285abb 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.15 require ( github.com/eclipse/paho.mqtt.golang v1.2.0 github.com/frankban/quicktest v1.10.2 - github.com/tinygo-org/tinyfs v0.0.0-20210514090915-924e60a7bcf8 + github.com/tinygo-org/tinyfs v0.0.0-20210620184125-5b00ebcf68bb ) diff --git a/go.sum b/go.sum index c049244..0b5d7e7 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/tinygo-org/tinyfs v0.0.0-20210514004344-b02c062d12c9 h1:66or7MohOph3x github.com/tinygo-org/tinyfs v0.0.0-20210514004344-b02c062d12c9/go.mod h1:HGuyo42bGd1zWSuS1gwgyyjN36ZZMlEpwM0vSrglmXc= github.com/tinygo-org/tinyfs v0.0.0-20210514090915-924e60a7bcf8 h1:pYwuKe1XuNeJnGV1UjeZ0FhuZ5+lapIq1NUmGacbBwo= github.com/tinygo-org/tinyfs v0.0.0-20210514090915-924e60a7bcf8/go.mod h1:HGuyo42bGd1zWSuS1gwgyyjN36ZZMlEpwM0vSrglmXc= +github.com/tinygo-org/tinyfs v0.0.0-20210620184125-5b00ebcf68bb h1:lgwaY6CLUvZoH4DMwHn3vKjYRx6npRX1FwjWuJEpZao= +github.com/tinygo-org/tinyfs v0.0.0-20210620184125-5b00ebcf68bb/go.mod h1:HGuyo42bGd1zWSuS1gwgyyjN36ZZMlEpwM0vSrglmXc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= tinygo.org/x/drivers v0.16.0/go.mod h1:uT2svMq3EpBZpKkGO+NQHjxjGf1f42ra4OnMMwQL2aI=