Skip to content

Commit

Permalink
Added doc + little fix
Browse files Browse the repository at this point in the history
Moved arduino code to another folder
Completed french part of readme
  • Loading branch information
73VW committed May 2, 2018
1 parent a88edc0 commit 7db392d
Show file tree
Hide file tree
Showing 37 changed files with 1,531 additions and 4 deletions.
51 changes: 51 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,54 @@ This package can be installed via :code:`pip install arduinozore`.

We are still working on this README.
------------------------------------

Français
--------

L'installation est aisée. Le package se trouvant sur pypi, il suffit de l'installer via la commande

.. code-block:: bash
pip install arduinozore
Lors du premier lancement, si aucun dossier de configuration n'est trouvé, il est créé.

**Attention** Il est nécessaire d'avoir une connection internet pour utiliser pip et lors du premier lancement de l'application. Des fichiers doivent être téléchargés depuis internet.

Pour afficher l'aide, la commande suivante est diponible

.. code-block:: bash
arduinozore --help
usage: arduinozore [-h] [-hp HTTP_PORT] [-hsp HTTPS_PORT] [-a path]
[--newconfig]
Arduinozore server
optional arguments:
-h, --help show this help message and exit
-hp HTTP_PORT, --http_port HTTP_PORT
Server http port. Default 8000
-hsp HTTPS_PORT, --https_port HTTPS_PORT
Server https port. Default 8001. Used for sockets too.
-a path, --arduino path
Path where arduino source code will be generated.
--newconfig Delete actual config and make a new one. Warning.
En cas de problème, il est possible de supprimer la configuration et la regénérer avec la commande

.. code-block:: bash
arduinozore --newconfig
Il est possible de spécifier les ports http et https. Par défaut les ports 8000 et 8001 sont utilisés. Pour ce faire, les options suivantes sont disponibles

.. code-block:: bash
arduinozore -hp 80 -hsp 443
Afin de récupérer le script arduino pour pouvoir le flasher, il est possible de l'obtenir avec l'option `-a` en donnant le path cible.

.. code-block:: bash
arduinozore -a /destination/path/for/arduino/script
4 changes: 2 additions & 2 deletions arduinozore/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def main():
p.add_argument('-hp',
'--http_port',
type=int,
help='Server http port. Default 80')
help='Server http port. Default ' + str(PORT))
p.add_argument('-hsp',
'--https_port',
type=int,
help='Server https port. Default 443. Used for sockets too.')
help='Server https port. Default ' + str(SSL_PORT) + '. Used for sockets too.')
p.add_argument('-a',
'--arduino',
type=str,
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions arduinozore/install_cert.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -xe

echo "Creating ssl certificates..."
cd ~/.arduinozore/certs >/dev/null 2>/dev/null
yes "" | openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout myserver.crt.key -out myserver.crt.pem >/dev/null 2>/dev/null
3 changes: 1 addition & 2 deletions arduinozore/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ def path(root, *a):
CARD_CONFIG_FOLDER = path(CONFIG_FOLDER, 'card')

ARDUINO_CODE_FILE_NAME = 'arduinozore.ino'
ARDUINO_FILE_PATH = path(ROOT, '..', 'arduino',
'arduinozore', ARDUINO_CODE_FILE_NAME)
ARDUINO_FILE_PATH = path(ROOT, 'arduino', 'arduinozore', ARDUINO_CODE_FILE_NAME)
2 changes: 2 additions & 0 deletions arduinozore/static_installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

set -xe

echo "Installing static files..."
#semantic
cd ~/.arduinozore/static >/dev/null 2>/dev/null
Expand Down
1 change: 1 addition & 0 deletions doc/manuelUtilisateur/.latexmkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$clean_ext = "xdv";
68 changes: 68 additions & 0 deletions doc/manuelUtilisateur/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
ifeq ('$(SOURCE_EXT)', '')
SOURCE_EXT=rst md
endif
SOURCES:=$(foreach ext, $(SOURCE_EXT), $(wildcard *.$(ext)))
ifeq ('$(DEST_EXT)', '')
DEST_EXT=pdf
endif
DESTINATIONS:=$(foreach source, $(SOURCES), $(addsuffix .$(DEST_EXT),$(basename $(source))))
GENERATED_DIR=generated

# clean files
CLEAN_EXT=pdf aux fdb_latexmk fls out tex toc xdv
CLEAN_SOURCES:=$(foreach ext, $(CLEAN_EXT), $(wildcard *.$(ext)))

help: ## Show help
@printf "Technical report Creator using pandoc\
\n\n\
Usage : make all \
SOURCE_EXT=<SOURCE_EXT> \
DEST_EXT=<DEST_EXT>\n\n\
SOURCE_EXT: Source file(s) extension.\n\tCan either be rst, md or tex. If not supplied, rst and md files are searched by default.\n\n\
DEST_EXT: Destination file(s) extension.\n\tCan either be md, tex or pdf. If not supplied, pdf is made by default.\n";

.PHONY: all

all: ${DESTINATIONS} ## Build all rst or md files to pdf

%.md: %.rst ## Converts from rst to md
pandoc $< \
--filter tools/rst_filter.py \
--output $@

%.tex: %.rst tools/project_infos.yaml ## Converts from rst to tex
pandoc $< \
--filter tools/rst_filter.py \
--lua-filter tools/getMetadata.lua \
--standalone \
--listings \
--to latex \
--template tools/template.tex \
--top-level-division section \
--output $@

%.tex: %.md tools/project_infos.yaml ## Converts from md to tex
pandoc $< \
--filter tools/md_filter.py \
--lua-filter tools/getMetadata.lua \
--standalone \
--listings \
--to latex \
--template tools/template.tex \
--top-level-division section \
--output $@

%.pdf: %.tex ## Converts from tex to pdf
latexmk -pdf -xelatex $<
latexmk -c $<
"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" $@ &

%.json: %.md
pandoc $< --to json --lua-filter=getMetadata.lua | python -m json.tool > ${<:.md=.json}


%.json: %.rst
pandoc $< --to json --lua-filter=getMetadata.lua | python -m json.tool > ${<:.rst=.json}

clean:
rm $(CLEAN_SOURCES)
Binary file added doc/manuelUtilisateur/ManuelUtilisateur.pdf
Binary file not shown.
Binary file added doc/manuelUtilisateur/img/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions doc/manuelUtilisateur/tools/getMetadata.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- read metadata file into string
local metafile = io.open('tools/project_infos.yaml', 'r')
local content = metafile:read("*a")
metafile:close()
-- get metadata
local default_meta = pandoc.read(content, "markdown").meta

return {
{
Meta = function(meta)
-- use default metadata field if it hasn't been defined yet.
for k, v in pairs(default_meta) do
if meta[k] == nil then
meta[k] = v
end
end
return meta
end,
}
}
48 changes: 48 additions & 0 deletions doc/manuelUtilisateur/tools/md_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python

"""
Pandoc filter to convert all regular text to uppercase.
Code, link URLs, etc. are not affected.
"""

import re

from pandocfilters import Image
from pandocfilters import RawInline
from pandocfilters import toJSONFilter


def mdFilter(key, value, format, meta):
"""
Filter datas.
First part search for latex reference to figure and writes them
as RawInline thereby backslashes are not escaped. It also removes
the extra $ symbols.
Second part search for images and set a label in the description
in order to be able to make a reference to them.
"""
if key == 'Str':
if re.search("\$ref.*\$", value):
# if we find a link, set it as raw link and re-add a
# backslash before the ref keyword and remote
value = value.replace("$", "")
val = RawInline('latex', "\\" + value)
return val

if key == 'Image':
[attrs, caption, src] = value
# this means the image label hasn't been modified yet
# (the mardown file doesn't come from a rst file)
if caption[-1]['t'] != 'RawInline':
new_capt = src[0]
# add \label{IMAGE_LABEL} to the picture description
new_desc = "\\" + "label{" + new_capt + "}"
caption.append(RawInline('latex', new_desc))
return Image(attrs, caption, src)


if __name__ == "__main__":
toJSONFilter(mdFilter)
54 changes: 54 additions & 0 deletions doc/manuelUtilisateur/tools/project_infos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Arduinozore
subtitle: Conception OS
lang: fr
language: french
author:
- lastname: Pedretti
firstname: Maël
- lastname: Neto Da Silva
firstname: André
- lastname: Gander
firstname: Laurent

responsable:
- lastname: Cortinovis
firstname: Claudio

date: \today
pagesize: a4

institut:
name: HE-Arc
logo: img/logo.jpg
logo_scale: 0.6

# project_logo:
# project_logo_scale: 0.4

# styles
#alignment: <alignment>
fontsize: 12pt
colorlinks: darkblue

documentclass: scrreprt
documentoptions: twoside

numbersections: true

abstractontitlepage: true

toc: true
toc-depth: 2
lof: true

abstract: |
\section*{Résumé}
Le projet Arduinozore a été réalisé dans le cadre du cours de Conception OS, un module de 3ème année de Bachelor au sein de la Haute-École Arc — Ingénierie, section Développement Logiciel et Multimédia. Le présent document décrit l'installation et l'utilisation du logiciel.
Arduinozore est un programme en Python qui permet de visualiser les valeurs de capteurs branchés sur un Arduino et connectés à un ordinateur ou un RaspberryPi. Au travers d'un interface web, il facilite la configuration et la récupération des données.
\section*{Abstract}
The Arduinozore project was realized within the context of the OS conception course, a 3rd year Bachelor module within the Arc-Engineering High School, section Software and Multimedia Development. This document describes the install and use of the software.
Arduinozore is a program in Python that allows you to vizualise datas from sensors wired to an Arduino and connected to a computer or a RaspberryPi. Through a web interface it facilitates the configuration and fetch of datas.
---
44 changes: 44 additions & 0 deletions doc/manuelUtilisateur/tools/rst_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python

"""
Pandoc filter to convert all regular text to uppercase.
Code, link URLs, etc. are not affected.
"""

import re

from pandocfilters import Image
from pandocfilters import RawInline
from pandocfilters import toJSONFilter


def rstFilter(key, value, format, meta):
"""
Filter datas.
First part search for latex reference to figure and writes them
as RawInline thereby backslashes are not escaped.
Second part search for images and set a label in the description
in order to be able to make a reference to them.
"""
if key == 'Str':
if re.search("\$ref", value):
# if we find a link, set it as raw link and re-add a
# backslash before the ref keyword
return RawInline('latex', value[:1] + "\\" + value[1:])
elif re.search(".*}\$", value):
return RawInline('latex', value)

elif key == 'Image':
[attrs, caption, src] = value
new_capt = src[0]
# add \label{IMAGE_LABEL} to the picture description
new_desc = "\\" + "label{" + new_capt + "}"
caption.append(RawInline('latex', new_desc))
return Image(attrs, caption, src)


if __name__ == "__main__":
toJSONFilter(rstFilter)
Loading

0 comments on commit 7db392d

Please sign in to comment.