Skip to content

gooz-project/gooz-os-v1.0.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gooz Project for ESP32

The Gooz project acts as an operating system and aims at a Linux experience for microcontrollers. It includes many features such as general microcontroller usage, package management system and IoT based operations.

Contributors

  • Gorkem Aktas
  • Ozgur Karaaslan
  • Arda Sonmez
  • Buket Ozbay

Basics

Basic GOOZ commands to use operating system like Linux

Login the system

>>> INFO:GoozOs is starting...
>>> Username -> admin
>>> Password -> 0000
>>> INFO:Welcome admin
  • Default username is “admin” and password is “0000”. It can be changed with system configuration settings.

list Command

>>> list
  • Lists available functions that user can use.

help Command

>>> help
---OUTPUT---
ls
pwd
cd
rm
rmdir
cat
clear
echo
touch
mkdir
mv
cp
list
INFO:For more information about commands -> help [COMMAND]
  • Shows some fundamental commands that can be used by user as seen in the example.

    >>> help pwd
    ---OUTPUT---
    INFO:Usage -> pwd
    INFO:prints the current working directory
    • Helps about a specific command as seen in the example.

history Command

>>> history 
  • Shows past commands used by user.

clear Command

>>> clear
  • Clears the terminal screen.

delay Command

delay [TIME]
  • Delays all programs as much as [TIME] seconds.

reset Command

>>> reset
  • Resets the system.

shutdown Command

>>> shutdown
  • Shuts the system.

System Configuration

System default settings and configurations of GoozOS.

Show Configs

conf show #Show all configs of GoozOS
conf show [CONFIG_PATH] #Show the config value in given [CONFIG_PATH]

conf show system
>>>{'machine': 'ESP32', 'version': '0.0.1'}

conf show system/machine
>>> ESP32
  • [CONFIG_PATH] can refer to a single configuration or multiple configurations
  • Configurations format is JSON

Changing Configurations

>>> conf change [CONFIG_PATH] [NEW_VALUE] 
# Change the value of the variable at [CONFIG_PATH] as [NEW_VALUE]

>>> conf change user/password 1234
The value which refers to "user/password" successfully changed as "1234"
  • Changing configurations does not support multiple changes. That means the [CONFIG_PATH] must refer to a single configuration.
  • System configuration does not support adding new configuration. If you need new key-value type data you can use Environment Variables.
>>> conf change user/username [CURRENT_PASSWORD] [NEW_USERNAME] 
>>> conf change user/password [CURRENT_PASSWORD] [NEW_PASSWORD]
  • To change username and password, current password should be given as above.

Environment Variables

Environment variables of GoozOS

Environent Variable Format

  • Variables are stored in etc/env/env_variables.txt
  • Environment variables have fallowing format in etc/env/env_variables.txt
📎 exampleKey=example variable value message=Hello Gooz! defGpio=pin var gpio --name myPin --pin 2 --type OUT pinConfig=--name myPin --pin 2 --type OUT
  • Variable key must be one word, it can not contain special characters such as ‘=’ but it can contain ‘_’ character.
  • Variable value supports multiple word and special characters except ‘=’ and python default escape characters

What is Environment Variable

  • Environment variable can store value and can be called anywhere in the system.
  • If GoozEngine sees $[VARIABLE_KEY] in any command it will change it to [VARIABLE_KEY]

Variable Monitoring

>>> env # Show all saved environment variables
>>> env [VARIABLE_KEY] # Show environment variable named [VARIABLE_KEY]
  • Also, echo command can be used to print any variable value
>>> echo $[VARIABLE_KEY] # Show environment variable named [VARIABLE_KEY]
  • echo command prints everything written after it. It supports environment variables too.

Adding and Changing Variables

>>> export [VARIABLE_KEY]=[VARIABLE_VALUE]

>>> export message=Hello Gooz! 
#It will add environment variable in etc/env/env_variables.txt

The following way can also be used for adding or changing variable

>>> $[VARIABLE_KEY] = [VARIABLE_VALUE]

>>> $message = Hello Gooz!
#It will add environment variable in etc/env/env_variables.txt
  • If the key named [VARIABLE_KEY] already exist, the value is changed to [VARIABLE_VALUE]
  • If there is no key named [VARIABLE_KEY], the value named [VARIABLE_VALUE] will be created.

Variable Removing

>>> unset [VARIABLE_KEY] # Delete the variable named [VARIABLE_KEY]

>>> unset message # Delete the variable named 'message'

Example Usage

>>> export pinConfig=--name myPin --pin 2 --type OUT
---OUTPUT---
INFO:The variable added successfully: pinConfig=--name myPin --pin 2 --type OUT

>>> env pinConfig
---OUTPUT---
--name myPin --pin 2 --type OUT

>>> pin var gpio $pinConfig

INFO:The var pin named new successfully registered
---OUTPUT---
{'--pin': '2', '--type': 'OUT', 'pinType': 'gpio', '--name': 'myPin'}

>>> pin gpio write myPin 1 

GPIO

Commands for GPIO pins

GPIO Help

>>> pin gpio help  # Gives general information about gpio

>>> pin gpio help [COMMAND_NAME] # Gives information about gpio [COMMAND_NAME] command

>>> pin gpio help write
---OUTPUT---
INFO:Usage -> pin gpio write [PIN_NAME] [VALUE]
INFO:[VALUE] can be HIGH (1) or LOW (0)

Pin Registering

>>> pin var gpio –-name [PIN_NAME] --pin [PIN_NUMBER] --type [GPIO_TYPE]
# Creates new gpio pin named [PIN_NAME]

>>> pin var gpio --name myPin --pin 2 --type OUT
  • [PIN_NAME] must be unique and it does not support special characters except ‘_’
  • [PIN_NUMBER] can be any gpio pin number.
  • [GPIO_TYPE] can be OUT, IN, ALT, OPENDRAIN or ALTOPENDRAIN

Registered Pin Commands


Update

>>> pin gpio update [PIN_NAME] --[VALUE_TO_CHANGE] [NEW_VALUE]
# Updates the [VALUE_TO_CHANGE] value of the gpio pin named [PIN_NAME] to [NEW_VALUE]

>>> pin gpio update myPin --pin 3
  • Pin update command supports multiple value changes.

    >>> pin gpio update myPin --pin 2 --type OUT

Show

>>> pin gpio show # Shows all gpio pins

>>> pin gpio show [PARAMETER]:[VALUE_TO_SEARCH_FOR] # Shows specific gpio pins
>>> pin gpio show pin:2 # Shows gpio pins value 2

Delete

>>> pin gpio delete [PIN_NAME] # Deletes gpio pin named [PIN_NAME]
>>> pin gpio delete myPin 

>>> pin gpio delete all # Deletes all gpio pins

GPIO Pin Usage


Writing GPIO Pin

>>> pin gpio write [PIN_NAME] [VALUE] # Write value to gpio pin named [PIN_NAME]

>>> pin gpio write myPin HIGH
  • A gpio pin supports digital voltage (HIGH or LOW) , analog values are not supported.
    • PWM pins can be used to writing analog voltage values.
  • [VALUE] can be HIGH (1) and LOW (0)

Reading GPIO Pin

>>> pin gpio read [PIN_NAME] # Read value from gpio pin named [PIN_NAME]

>>> pin gpio read myPin
---OUTPUT---
1

ADC

Commands for Analog to Digital Converter (ADC) pins.

ADC Info

  • Gooz ADC pins read a raw analog value in the range 0-4096.

ADC Help

>>> pin adc help  # Gives general information about gpio

>>> pin adc help [COMMAND_NAME] # Gives information about gpio [COMMAND_NAME] command

>>> pin adc help read
---OUTPUT---
Info:Usage -> pin adc read [PIN_NAME] [READ_COUNT]
Info:reads value [READ_COUNT] times

Pin Registering

>>> pin var adc –-name [PIN_NAME] --pin [PIN_NUMBER]
# Create new gpio pin named [PIN_NAME]

>>> pin var adc --name myPin --pin 2
  • [PIN_NAME] must be unique and it does not support special characters except ‘_’
  • [PIN_NUMBER] can be any adc pin number. Current microcontroller must support this ADC pin.

Registered Pin Commands


Update

>>> pin adc update [PIN_NAME] --[VALUE_TO_CHANGE] [NEW_VALUE]
# Update the [VALUE_TO_CHANGE] value of the adc pin named [PIN_NAME] to [NEW_VALUE]

>>> pin adc update myPin --pin 3
  • Pin update command supports multiple value changes.

    >>> pin adc update myPin --pin 2 --type OUT

Show

>>> pin adc show # Show all adc pins

>>> pin adc show [PARAMETER]:[VALUE_TO_SEARCH_FOR] # Show specific adc pins
>>> pin adc show pin:2 #Show adc pins value 2

Delete

>>> pin adc delete [PIN_NAME] # Delete adc pin named [PIN_NAME]
>>> pin adc delete myPin 

>>> pin adc delete all # Delete all adc pins

ADC Pin Usage


Reading ADC Pin

>>> pin adc read [PIN_NAME] [READ_COUNT] 
# Reads the value [COUNT] times from the adc pin named [PIN_NAME]
  • [READ_COUNT] is not necessary.
>>> pin adc read myPin
---OUTPUT---
2048

Listening ADC Pin

  • Listen command supports many reads from given adc pin.
  • Listen command will create a listen thread operation.
    • For stopping, showing current operations and more information please visit thread page
>>> pin adc listen [PIN_NAME] # Read value from adc pin named [PIN_NAME] every 1 second
>>> pin adc listen myPin
  • Listen command accepts some parameters

    >>> pin adc listen [PIN_NAME] --[PARAMETER_KEY] [PARAMETER_VALUE] 
    • Parameters:

      • --file [FILE_NAME]
        • If this parameter exists, the readed value will be written in the given [FILE_NAME]
        • [FILE_NAME] format can be directly file name or file name with path
          • listen_values.txt
          • /user_files/listen_values.txt
      • --date [DATE_BOOL]
        • Default value of [DATE_BOOL] is 1
        • [DATE_BOOL] can be 1 or 0
        • If [DATE_BOOL] 1, the readed value will be written with date
      • --loop [LOOP_COUNT]
        • Default value of [LOOP_COUNT] is -1 that means, it will read until stopped manually.
        • If [LOOP_COUNT] is bigger than 0, the number of reads will be the given number.
      • --delay [SLEEP_TIME]
        • Default value of [SLEEP_TIME] is 1
        • [SLEEP_TIME] can be any float number.
        • Listen command waits as [SLEEP_TIME] (unit = second) between two read operations.
      • --end [END_CHARACTER]
        • Default value of [END_CHARACTER] is “\n”
        • [END_CHARACTER] can be any character
        • Listen command prints given [END_CHARCTER] after readed value in files.

      Example Usage of Listen Command

      	>>> pin adc listen myPin --file values.txt --delay 0.5
      • Every 0.5 second the readed value of myPin is written to file named values.txt

PWM

Commands for PWM pins.

PWM Help

>>> pin pwm help
  • Gives general information about pwm and it’s commands.
pin pwm help [COMMAND_NAME]
  • Gives information about specific pwm [COMMAND_NAME] command.
>>> pin pwm help write
---OUTPUT---
INFO:Usage -> pin pwm write [PIN_NAME] [PWM_DUTY_CYCLE]
INFO:sets duty cycle from 0 to 1023 with [PWM_DUTY_CYCLE]
  • Example usage for PWM help command

Pin Registering

Users must register a pin with a name, pin number and pwm frequency before using the PWM pin.

pin var pwm --name [PIN_NAME] --pin [PIN_NUMBER] --freq [PWM_FREQUENCY]
  • About PWM Parameters
    • [PIN_NAME] must be unique and it does not support special characters except ‘_’
    • [PIN_NUMBER] can be any pwm pins.
    • [PWM_FREQUENCY] can set PWM frequency from 1Hz to 40MHz. Default pwm frequency is 5000Hz.

Registered Pin Commands

Update

pin pwm update [PIN_NAME] --[VALUE_TO_CHANGE] [NEW_VALUE]
  • Updates the [VALUE_TO_CHANGE] value of the pwm pin named [PIN_NAME] to [NEW_VALUE]
>>> pin pwm update my_pin --pin 3
  • Example usage for updating pwm pins. According to the example, new value of pwm pin number is 3.

    >>> pin pwm update my_pin --pin 3 --name my_pwm
    • Example usage of pin update command that also supports multiple value changes

Show

>>> pin pwm show
  • Shows information about all existing pwm pins.
pin pwm show [PARAMETER]:[VALUE_TO_SEARCH_FOR]
  • Shows information about a specific pwm pin which is called by user.
>>> pin pwm show name:my_pwm
  • Example usage for showing a specific pwm pin

Delete

pin pwm delete [PIN_NAME]

pin pwm delete all
  • Deletes the pwm pin named [PIN_NAME]
  • pin pwm delete all command deletes all registered pwm pins.
>>> pin pwm delete my_pwm
  • Example usage for deleting a pwm pin

Usage of PWM Pins


Writing PWM Pin

pin pwm write [PIN_NAME] [PWM_DUTY_CYCLE]
  • Writes [PWM_DUTY_CYCLE] to pwm pin named [PIN_NAME]
  • PWM pins support analog voltage values. Digital voltage values are not supported.
    • GPIO pins can be used for writing digital voltage values.
  • [PWM_DUTY_CYCLE] sets duty cycle from 0 to 1023 (0v - 3.3v). If duty cycle is 0, pwm pin is at the lowest value which means it is closed.
>>> pin pwm write my_pwm 512
  • Example usage for writing a pwm pin named my_pwm

Closing PWM Pin

pin pwm close [PIN_NAME]
  • Turns off the running pwm pin named [PIN_NAME]

UART

UART ****is a hardware communication protocol that uses asynchronous serial communication with configurable speed.

Uart Help

>>> pin uart help  # Gives general information about uart

>>> pin uart help [COMMAND_NAME] # Gives information about uart [COMMAND_NAME] command

>>> pin uart help write
---OUTPUT---
INFO:Usage -> pin gpio write [PIN_NAME] [VALUE]
INFO:sends [TX_DATA] to the [PIN_NAME]

Pin Registering

>>> pin var uart --name [PIN_NAME] --id [UART_ID] --baud [BAUDRATE]
# Creates new uart pin named [PIN_NAME]

>>> pin var uart --name myPin --id 2 --baud 115200
  • [PIN_NAME] must be unique and it does not support special characters except ‘_’

  • [UART_ID] have to be 0 ,1 or 2 as below.

    Untitled

  • [BAUDRATE] is 9600 as default. Also it can be assigned manually.

Registered Pin Commands


Update

>>> pin uart update [PIN_NAME] --[VALUE_TO_CHANGE] [NEW_VALUE]
# Updates the [VALUE_TO_CHANGE] value of the uart pin named [PIN_NAME] to [NEW_VALUE]

>>> pin uart update myPin --name myUartPin
  • Pin update command supports multiple value changes.

    >>> pin uart update myPin --name myUartPin --id 1

Show

>>> pin uart show  # Shows all uart pins

>>> pin uart show [PARAMETER]:[VALUE_TO_SEARCH_FOR]  # Shows specific uart pins
>>> pin uart show pin:2  # Shows uart pins with a pin value of 2

Delete

>>> pin uart delete [PIN_NAME] # Deletes uart pin named [PIN_NAME]
>>> pin uart delete myPin 

>>> pin uart delete all # Deletes all uart pins

GPIO Pin Usage


Sending Data from Uart Pin

>>> pin uart write [PIN_NAME] --data [TX_DATA] # Sends [TX_DATA] to uart pin named [PIN_NAME]

>>> pin uart write myPin --data Hi
>>> pin uart write myPin --data "Hello World!"
  • [TX_DATA] have to be in double quotes if it is more than one word.

Reading Data from Uart Pin

>>> pin uart read [PIN_NAME] # Reads last taken data from uart pin named [PIN_NAME]
>>> pin uart read myPin

Reading Data Continuously from Uart Pin

  • Listen command supports many reads from given uart pin.
  • Listen command will create a listen thread operation.
    • For stopping, showing current operations and more information please visit thread page
>>> pin uart listen [PIN_NAME] # Reads value from uart pin named [PIN_NAME] every 1 second
>>> pin uart listen myPin
  • Listen command accepts some parameters

    >>> pin uart listen [PIN_NAME] --[PARAMETER_KEY] [PARAMETER_VALUE] 
    • Parameters:

      • --file [FILE_NAME]
        • If this parameter exists, the readed value will be written in the given [FILE_NAME]
        • [FILE_NAME] format can be directly file name or file name with path
          • listen_values.txt
          • /user_files/listen_values.txt
      • --date [DATE_BOOL]
        • Default value of [DATE_BOOL] is 1
        • [DATE_BOOL] can be 1 or 0
        • If [DATE_BOOL] 1, the readed value will be written with date
      • --loop [LOOP_COUNT]
        • Default value of [LOOP_COUNT] is -1 that means, it will read until stopped manually.
        • If [LOOP_COUNT] is bigger than 0, the number of reads will be the given number.
      • --delay [SLEEP_TIME]
        • Default value of [SLEEP_TIME] is 1
        • [SLEEP_TIME] can be any float number.
        • Listen command waits as [SLEEP_TIME] (unit = second) between two read operations.
      • --end [END_CHARACTER]
        • Default value of [END_CHARACTER] is “\n”
        • [END_CHARACTER] can be any character
        • Listen command prints given [END_CHARACTER] after readed value in files.

      Example Usage of Listen Command

      	>>> pin uart listen myPin --file values.txt --delay 0.5
      • Every 0.5 second the readed value of myPin is written to file named values.txt

I2C

I2C (Inter-Integrated Circuit) is a two wire serial interface.

I2C Help

>>> pin i2c help  # Gives general information about i2c

>>> pin i2c help [COMMAND_NAME] # Gives information about i2c [COMMAND_NAME] command

>>> pin i2c help write
---OUTPUT---
INFO:Usage -> pin i2c delete "pin_name"
INFO:sends [TX_DATA] to [PIN_NAME]

Pin Registering

>>> pin var i2c --name [PIN_NAME] --scl [SCL_PIN] --sda [SDA_PIN] --address [ADDRESS] --baud [BAUDRATE]]
# Creates new i2c pin named [PIN_NAME]

>>> pin var i2c --name myPin --scl 22 --sda 21 --address 0x10 --baud 115200
  • [PIN_NAME] must be unique and it does not support special characters except ‘_’
  • [SCL_PIN] is serial clock line pin.
  • [SDA_PIN] is serial data line pin.
  • [ADDRESS] is address of connected slave device.
  • [BAUDRATE] is 10000 as default. Also it can be assigned manually.

Registered Pin Commands


Update

>>> pin i2c update [PIN_NAME] --[VALUE_TO_CHANGE] [NEW_VALUE]
# Updates the [VALUE_TO_CHANGE] value of the i2c pin named [PIN_NAME] to [NEW_VALUE]

>>> pin i2c update myPin --name myI2cPin
  • Pin update command supports multiple value changes.

    >>> pin i2c update myPin --scl 5 --sda 4

Show

>>> pin i2c show  # Shows all i2c pins

>>> pin i2c show [PARAMETER]:[VALUE_TO_SEARCH_FOR]  # Shows specific i2c pins
>>> pin i2c show pin:2  # Shows i2c pins with a pin value of 2

Delete

>>> pin i2c delete [PIN_NAME] # Deletes i2c pin named [PIN_NAME]
>>> pin i2c delete myPin 

>>> pin i2c delete all # Deletes all i2c pins

I2C Pin Usage


Sending Data from I2C Pin

>>> pin i2c write [PIN_NAME] --data [TX_DATA] # Sends [TX_DATA] to i2c pin named [PIN_NAME]

>>> pin i2c write myPin --data Hi
>>> pin i2c write myPin --data "Hello World!"
  • [TX_DATA] have to be in double quotes if it is more than one word.

Reading Data from I2C Pin

>>> pin i2c read [PIN_NAME] --byte [BYTE_SIZE]  # Takes data from [PIN_NAME] in lenght [BYTE_SIZE]

>>> pin i2c read myPin --byte 10

Reading Data Continuously from I2C Pin

>>> pin i2c listen [PIN_NAME]  # Takes data from [PIN_NAME] continuously in thread
>>> pin i2c listen myPin

>>> pin i2c listen stop  # stops reading message from all i2c pins

Reading Data Continuously from I2C Pin

  • Listen command supports many reads from given i2c pin.
  • Listen command will create a listen thread operation.
    • For stopping, showing current operations and more information please visit thread page
>>> pin i2c listen [PIN_NAME] # Reads value from i2c pin named [PIN_NAME] every 1 second
>>> pin i2c listen myPin
  • Listen command accepts some parameters

    >>> pin i2c listen [PIN_NAME] --[PARAMETER_KEY] [PARAMETER_VALUE] 
    • Parameters:

      • --file [FILE_NAME]
        • If this parameter exists, the readed value will be written in the given [FILE_NAME]
        • [FILE_NAME] format can be directly file name or file name with path
          • listen_values.txt
          • /user_files/listen_values.txt
      • --date [DATE_BOOL]
        • Default value of [DATE_BOOL] is 1
        • [DATE_BOOL] can be 1 or 0
        • If [DATE_BOOL] 1, the readed value will be written with date
      • --loop [LOOP_COUNT]
        • Default value of [LOOP_COUNT] is -1 that means, it will read until stopped manually.
        • If [LOOP_COUNT] is bigger than 0, the number of reads will be the given number.
      • --delay [SLEEP_TIME]
        • Default value of [SLEEP_TIME] is 1
        • [SLEEP_TIME] can be any float number.
        • Listen command waits as [SLEEP_TIME] (unit = second) between two read operations.
      • --end [END_CHARACTER]
        • Default value of [END_CHARACTER] is “\n”
        • [END_CHARACTER] can be any character
        • Listen command prints given [END_CHARACTER] after readed value in files.

      Example Usage of Listen Command

      	>>> pin i2c listen myPin --file values.txt --delay 0.5
      • Every 0.5 second the readed value of myPin is written to file named values.txt

SPI

SPI (Serial Peripheral Interface) is a synchronous serial communication interface that supports full-duplex mode where data can be sent and received simultaneously.

SPI Help

>>> pin spi help  # Gives general information about spi 

>>> pin spi help [COMMAND_NAME] # Gives information about spi [COMMAND_NAME] command

>>> pin spi help write
---OUTPUT---
INFO:Usage -> pin spi write [PIN_NAME] --data [TX_DATA]
INFO:sends [TX_DATA] to spi pin named [PIN_NAME]

Pin Registering

>>> pin var spi --name [NAME] --id [SPI_ID] --baud [BAUDRATE] --ss [SLAVE_SELECT_PIN] 
# Creates new spi pin named [PIN_NAME]

>>> pin var spi --name myPin --id 2 --baud 115200 --ss 6
  • [PIN_NAME] must be unique and it does not support special characters except ‘_’

  • [SPI_ID] have to be 1 or 2 as below.

    Untitled

  • [BAUDRATE] is 4000000 as default. Also it can be assigned manually.

Registered Pin Commands


Update

>>> pin spi update [PIN_NAME] --[VALUE_TO_CHANGE] [NEW_VALUE] 
# Updates the [VALUE_TO_CHANGE] value of the spi pin named [PIN_NAME] to [NEW_VALUE]

>>> pin spi update myPin --name mySPIPin
  • Pin update command supports multiple value changes.

    >>> pin spi update myPin --name mySPIPin --id 1

Show

>>> pin spi show # Shows all spi pins

>>> pin spi show [PARAMETER]:[VALUE_TO_SEARCH_FOR]  # Shows specific spi pins
>>> pin spi show pin:2  # Shows spi pins with a pin value of 2

Delete

>>> pin spi delete [PIN_NAME] # Deletes spi pin named [PIN_NAME]
>>> pin spi delete myPin 

>>> pin spi delete all # Deletes all spi pins

SPI Pin Usage


Sending Data from SPI Pin

>>> pin spi write [PIN_NAME] --data [TX_DATA] 
# Sends [TX_DATA] to spi pin named [PIN_NAME]

>>> pin spi write myPin --data Hi
>>> pin spi write myPin --data "Hello World!"
  • [TX_DATA] have to be in double quotes if it is more than one word.

Reading Data from SPI Pin

>>> pin spi read [PIN_NAME] --byte [BYTE_SIZE] # reads datas in length of [BYTE_SIZE] from spi pin named [PIN_NAME]
>>> pin spi read myPin --byte 10

Reading Data Continuously from I2C Pin

>>> pin spi  listen [PIN_NAME]  # Takes data from [PIN_NAME] continuously in thread
>>> pin spi listen myPin

>>> pin spi listen stop  # stops reading message from all spi pins

Reading Data Continuously from I2C Pin

  • Listen command supports many reads from given spi pin.
  • Listen command will create a listen thread operation.
    • For stopping, showing current operations and more information please visit thread page
>>> pin spi listen [PIN_NAME] # Reads value from spi pin named [PIN_NAME] every 1 second
>>> pin spi listen myPin
  • Listen command accepts some parameters

    >>> pin spi listen [PIN_NAME] --[PARAMETER_KEY] [PARAMETER_VALUE] 
    • Parameters:

      • --file [FILE_NAME]
        • If this parameter exists, the readed value will be written in the given [FILE_NAME]
        • [FILE_NAME] format can be directly file name or file name with path
          • listen_values.txt
          • /user_files/listen_values.txt
      • --date [DATE_BOOL]
        • Default value of [DATE_BOOL] is 1
        • [DATE_BOOL] can be 1 or 0
        • If [DATE_BOOL] 1, the readed value will be written with date
      • --loop [LOOP_COUNT]
        • Default value of [LOOP_COUNT] is -1 that means, it will read until stopped manually.
        • If [LOOP_COUNT] is bigger than 0, the number of reads will be the given number.
      • --delay [SLEEP_TIME]
        • Default value of [SLEEP_TIME] is 1
        • [SLEEP_TIME] can be any float number.
        • Listen command waits as [SLEEP_TIME] (unit = second) between two read operations.
      • --end [END_CHARACTER]
        • Default value of [END_CHARACTER] is “\n”
        • [END_CHARACTER] can be any character
        • Listen command prints given [END_CHARACTER] after readed value in files.

      Example Usage of Listen Command

      	>>> pin spi listen myPin --file values.txt --delay 0.5
      • Every 0.5 second the readed value of myPin is written to file named values.txt

WiFi

Wifi library helps to connect any hotspot wifis

Activating & deactivating wifi

wifi on
wifi off

Finding available wifis

wifi ls

Connecting wifi

wifi connect --name [SSID] --password [PASSWORD]

Disconnecting wifi

wifi disconnect

Active wifi connection status

wifi status # shows network connection

wifi ifconfig  # shows detailed network connection informations

Tools

Internal Temperature Sensor

Internal Temperature Sensor module of GoozOS

Printing CPU Temperature

>>> cpu_temp
  • Prints current CPU temperature as degree Celcius.
>>> cpu_temp -f
  • Prints current CPU temperature as degree Fahrenheit.

Internal Hall Sensor

Internal Hall Sensor module of GoozOS

Printing Magnetic Area Value

>>> hall
  • Prints value of current magnetic area.

RTC

Real Time Clock (RTC) module of GoozOS

RTC Info

  • Built-in RTC module stores time data as tuple format
    • Example Time: (2022, 4, 14, 3, 10, 8, 16, 797293)
    • 0 Year, 1 Month, 2 Day of Month, 3 Day of Week, 4 Hour, 5 Minute, 6 Second, 7 miliseconds
    • pin listen commands uses RTC when value of --date parameter is 1 .

RTC Commands

>>> rtc show
---OUTPUT---
(2022, 2, 14, 3, 12, 4, 15, 858697)
  • Shows current RTC data as tuple.
>>> rtc autoset
  • Sets time to current real time.
  • Wifi must be connected for rtc autoset command.
>>> rtc set
---OUTPUT---
Please enter 0'th value: [2019]
DEBUG:Date had taken!: (2019)
Please enter 1'th value: [c]
DEBUG:Date had taken!: (4)
.
.
.
  • Sets RTC manually.
  • rtc set command will want 7 integer data one by one.
  • If the given value equal to ‘c', value of current RTC does not change.

Calculator

Calculator module of GoozOS

Calculating operations

calc [OPERATION]
  • Calculates [OPERATION] and prints the result to terminal.
>>> calc 3+8/2
---OUTPUT---
7
  • Example usage for calculating operations
calc [OPERATION] > [VARIABLE]
  • Calculates [OPERATION] and prints the result to env_variables.txt file as [VARIABLE]

Usage

Usage module of GoosOS

Printing RAM and ROM Statuses

>>> usage
---OUTPUT---
Total ROM Size: 2.0MB
Used ROM Size: 0.359MB
Free ROM Size: 1.641MB
ROM Usage Percentage: 17.95%

Total RAM Size: 108.625KB
Used RAM Size: 46.391KB
Free RAM Size: 62.234KB
RAM Usage Percentage: 42.71%
  • Prints current RAM and ROM statuses as seen in the example.

Informations about Gooz File System

Client

Module for the remote terminal access with TCP-IP communication.

Starting the client

>>> client start --port [PORT]
>>> client start  # takes default port value as [PORT]
  • [PORT] can be assigned using “conf change client/port [PORT]” and can be used like above:
>>> conf change client/auto_start True # starts automatically the client on boot

Closing the client

>>> client close

Note: Com-port terminal cannot be used while client is running. If client is closed from remote access terminal, then com-port terminal can be used.

File Operations


Showing Current Path

>>> pwd

Showing Files and Directories

ls

ls [PATH]
  • Shows files and directories in current directory except hidden ones.
  • If [PATH] is entered, shows files and directories in [PATH] except hidden ones.
ls -a

ls [PATH] -a
  • Shows files and directories in current directory including hidden ones.
  • If [PATH] is entered, shows files and directories in [PATH] including hidden ones.

Changing Directory

cd [DIRECTORY]
  • Goes [DIRECTORY] path in the system.
>>> cd ..
  • Goes upper directory in the system.

Creating Directories and Files

mkdir [DIR_NAME]
>>> mkdir dir1

mkdir /[DIR_NAME]/[DIR_NAME]
>>> mkdir /directory/dir1
  • Creates an empty directory named [DIR_NAME] in current directory or given path /[DIR_NAME]/[DIR_NAME].
touch [FILE_NAME]
>>> touch file1

touch /[DIR_NAME]/[FILE_NAME]
>>> touch /directory/file1
  • Creates an empty file named [FILE_NAME] in current directory or given path /[DIR_NAME]/[FILE_NAME].

Deleting Directories and Files

rmdir [DIR_NAME]
>>> rmdir dir1

rmdir /[DIR_NAME]/[DIR_NAME]
>>> rmdir /directory/dir1
  • Deletes the directory recursively named [DIR_NAME] in current directory or given path /[DIR_NAME]/[DIR_NAME].
rm [FILE_NAME]
>>> rm file1

rm /[DIR_NAME]/[FILE_NAME]
>>> rm /directory/file1
  • Deletes the file named [FILE_NAME] in current directory or given path /[DIR_NAME]/[FILE_NAME].

Renaming and Moving Files

mv [FILE_NAME1] [FILE_NAME2]
  • Renames [FILE_NAME1] to [FILE_NAME2]
mv [FILE_NAME1] [FOLDER_NAME] [FILE_NAME2]
  • Moves [FILE_NAME1] to [FOLDER_NAME] as [FILE_NAME2]

Copying Files

cp [FILE_NAME1] [FILE_NAME2]
  • Copies [FILE_NAME1] to [FILE_NAME2] on the same path.
cp [FILE_NAME1] [FOLDER_NAME] [FILE_NAME2]
  • Copies [FILE_NAME1] to the bottom of the [FOLDER_NAME] as [FILE_NAME2]

Reading Files

cat [FILE_NAME]
>>> cat file1

cat /[DIR_NAME]/[FILE_NAME]
>>> cat /directory/file1
  • Reads the file named [FILE_NAME] in current directory or given path /[DIR_NAME]/[FILE_NAME].

Printing Data

echo [DATA]
  • Prints [DATA] to terminal.
>>> echo Hello World!
---OUTPUT---
Hello World!
  • Example usage for printing data
echo [DATA] > [FILE_NAME]
  • Prints [DATA] to a newly created [FILE_NAME]
echo [DATA] >> [FILE_NAME]
  • Prints [DATA] to an already existing [FILE_NAME]

Thread

  • Thread supports multiple operations in same time.
  • Thread tool can be used for running micropython scripts.
  • Also, pin listen commands are a thread operation.

Thread Usage

Thread Show

>>> thread show # Shows current thread operations and settings
--OUTPUT--
{'ID': 1, '--delay': '0', 'code_file_name': 'blink.py', 'type': 'code'}

Thread Start

>>> thread start [FILE_NAME] # Run file named [FILE_NAME] in thread
  • thread start command also accepts some parameters
    • Parameters:
      • --delay [SLEEP_TIME]
        • Default value of [SLEEP_TIME] is 1
        • [SLEEP_TIME] is can be any float number.
        • thread start command waits as [SLEEP_TIME] (unit = second) between two run operations.
      • --loop [LOOP_COUNT]
        • Default value of [LOOP_COUNT] is -1 that means, it will run file until stopped manually.
        • If [LOOP_COUNT] is bigger than 0, the number of runs will be the given number.

Thread Stop

>>> thread stop [THREAD_ID] # Stops thread operation by ID

Thread File Format

  • The same named variables in different thread operations causes errors!
    • But, same named functions does not cause errors

Example Thread Usage

  • ledblink.py
def blink():
    from machine import Pin
    import utime
    led = Pin(2,Pin.OUT)
    led.value(1)
    utime.sleep(1)
    led.value(0)
    utime.sleep(1)   
blink()
  • Imports must be in function
>>> thread start ledblink.py --delay 0
>>> thread show
---OUTPUT---
{'ID': 1, '--delay': '0',  'code_file_name': 'ledblink.py', 'type': 'code', '--loop':'-1'}
>>> thread stop 1

Package Installer

Package Install

pkg install [PACKAGE_NAME]

Package Uninstall

pkg uninstall [PACKAGE_NAME]

Package Installer Templates

For JSON file

{
    "name" : "tester",
    "codes" : [{"filename":"main.py","code":"def run():\\n    print('Hello from tester')"}],
    "managersnip":"    elif cmd_arr[0] == 'tester':\\n        try:\\n            import app.tester.main\\n            app.tester.main.run()\\n        except:\\n            print('This app is deleted')\\n"
}

There are 3 fields for packaging. These are name, codes and managersnip

Name field includes package name and this name also exists in .json file as a name

Codes field include .py files and their codes. Every code have to be written as string format. This format must be same Thonny IDE code styling. So \t does not be used.

Gooz Package Installer seperates these files and their codes, after it creates a application folder under app folder. The file which is [pkgmanager.py](http://pkgmanager.py) manages application orchestration. So, pkgmanager must include runner codes. It is provided with managersnip field in JSON file. Managersnip codes have to be like example JSON file.

For new line \\n must be used

Every application has any folder when turning on package, because every application contains only .py files. Unlimited py files can be used but not contain any folder.

Goozshell

Goozshell runs Gooz commands in a row.

# example.py

# pwd
# delay 3
# cpu_temp

>>> goozshell example.py
---OUTPUT---
/  # delays 3 second
48.9 degree Celcius

About

GoozOS RunTime Environment for ESP32 Microcontrollers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages