###### tags: `Sys.management`
# Sandbox
## project Setp by Step
1. Download OS and make ssh and wpa_supplicant.conf files in raspi card
2. Connection to raspi with either WLAN or LAN
3. Installation on Raspi
4. Do program on NetBeans
5. Clean and build the project
6. drag and drop **dist** with file **.jar** in raspi
7. commande raspi java -jar /home/pi/Documents/dist/ProjThinkerforge.jar
---
## 1 Download OS and make ssh and wpa_supplicant.conf files in raspi card
installer le ssh et le wpa_config et installer le système d'opération du raspberry ensuite créer un réseau et faire connecter le raspberry dessus afin de trouver son addresse IP
### utilisateur et pw du raspberry du sandbox

## Installation on Raspi
### install java thinkerforge
sudo apt install libtinkerforge-java
is installed to this location:
/usr/share/java/tinkerforge.jar
### install Brick Deamon
sudo apt-get install libusb-1.0-0 libudev1 procps
wget --backups=1 https://download.tinkerforge.com/tools/brickd/linux/brickd_linux_latest_armhf.deb
sudo dpkg -i brickd_linux_latest_armhf.deb
Updates can be installed by repeating the last two commands:
Updates can be installed by repeating the last two commands:
wget --backups=1 https://download.tinkerforge.com/tools/brickd/linux/brickd_linux_latest_armhf.deb
sudo dpkg -i brickd_linux_latest_armhf.deb
### Soft-Float Debian (armel)
If you have installed an Debian without hardware floating point unit support, you have to compile Brick Daemon from source.
First you have to download the source code from the download page and put it under the home directory.
After this you have to execute the following steps:
sudo apt-get install build-essential pkg-config libusb-1.0-0-dev libudev-dev procps
unzip Tinkerforge-brickd-vX.Y.Z-W-***.zip (modify filename)
cd Tinkerforge-brickd-vX.Y.Z-W-*** (modify folder name)
cd src/brickd
make
sudo make install
sudo update-rc.d brickd defaults
sudo /etc/init.d/brickd start
### Install Brick Viewer
To install the Brick Viewer software execute the following commands:(opération 3 avant 2)
sudo apt-get install python3 python3-pyqt5 python3-pyqt5.qtopengl python3-serial python3-tz python3-tzlocal
wget --backups=1 https://download.tinkerforge.com/tools/brickv/linux/brickv_linux_latest.deb
sudo dpkg -i brickv_linux_latest.deb
Updates can be installed by repeating the last two commands:
wget --backups=1 https://download.tinkerforge.com/tools/brickv/linux/brickv_linux_latest.deb
sudo dpkg -i brickv_linux_latest.deb
---
### Install .jar file for Netbeans
j'ai pas suivi donc jsp ce qu'il faut faire, par contre il a mis un livre en pdf sur le moodle qui peux être utile si t'as envie de lire 568 pages :abc: :100:
j'en ai marre de ce cours, je comprends pas grand chose et il fait toujours quelques choses de différent
---
pas faire seulement un compile mais faire un clean and compile
dans file il y a tout les dossiers, si pas visible faire un reset window dans window
### installation Java
sudo apt install openjdk-11-jre
## Projet TinkerForgeMVN
propeties
fichier pom.xml : beaucoup de libraires pour codes java
ajouter:
<dependencies>
<dependency>
<groupeId> com.tinkerforge </groupeId>
<artiactId> tinkerforge </artiactId>
<version> 2.1.31 </version>
</dependency>
</dependencies>
ensuite build with dependencies -> le code n'est plus rouge (plus d'erreurs)
pour formater : clique droit, formater
dans target, un fichire avec un nom a rallonge et en .jar se trouve ( généralement sous test-classes)
tools, java,
add platform
remote java standart..
- rapsi
- remplir les autres champs ( host: adresse IP ou nom, username: pi (généralment) pwd: ********* (pwd du raspi))
**IMPORTANT** : remote JRE Path
dans la console java :
javac
ls java* -lisah
cd /etc/alternatives/javac
ls - lisah java*
copier le lien sous java dans remote JRE Path sans le bin et le java (s'arrêter avant le bin)
clique droit sur le projet, properties, run, runtime Platform sélectionner la bonne platforme
#### Plusieurs classe main dans un même projet
il faut faire un clique droit sur le projet, propriété, run, main class -> browse -> choisir celui qu'on veut après cela il faut refaire un clean and build
### fichier dhcp
dhcpcd.conf
## Do program on NetBeans
import com.tinkerforge.IPConnection;
import com.tinkerforge.BrickletMotorizedLinearPoti;
public class ExampleSimple {
private static final String HOST = "localhost";
private static final int PORT = 4223;
// Change XYZ to the UID of your Motorized Linear Poti Bricklet
private static final String UID = "DaT";
private static final String UID2 = "D1z";
// Note: To make the example code cleaner we do not handle exceptions. Exceptions
// you might normally want to catch are described in the documentation
public static void main(String args[]) throws Exception {
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletMotorizedLinearPoti mlp1 =
new BrickletMotorizedLinearPoti(UID, ipcon); // Create device object
BrickletMotorizedLinearPoti mlp2 =
new BrickletMotorizedLinearPoti(UID2, ipcon);
ipcon.connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Get current position
do {
int position= mlp1.getPosition(); // Can throw com.tinkerforge.TimeoutException
mlp2.setMotorPosition(position, BrickletMotorizedLinearPoti.DRIVE_MODE_FAST, false);
System.out.println("Position: " + position); // Range: 0 to 100
System.out.println("test");
}while (true);
}
}
## commande raspi java -jar
