issue116:tuto2
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue116:tuto2 [2017/01/02 15:41] – créée auntiee | issue116:tuto2 [2017/01/13 14:31] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | In this series of articles, I will be building a text-based application with Free Pascal, using its text-based interface for user interaction. This will be combined with other, more modern, technologies such as database access using SQL and Web access with HTTP. The final aim of the project is to demonstrate how Pascal can be used to build a modern application, | + | **In this series of articles, I will be building a text-based application with Free Pascal, using its text-based interface for user interaction. This will be combined with other, more modern, technologies such as database access using SQL and Web access with HTTP. The final aim of the project is to demonstrate how Pascal can be used to build a modern application, |
- | In the previous part of this series, we put our complete application together using Free Vision for the user interface, Sqlite to create a local database, and CURL and XML to retrieve fresh data from an RSS feed from the Web to update our database. In this part, we will see various ways in which our application can run on a Raspberry Pi. | + | In the previous part of this series, we put our complete application together using Free Vision for the user interface, Sqlite to create a local database, and CURL and XML to retrieve fresh data from an RSS feed from the Web to update our database. In this part, we will see various ways in which our application can run on a Raspberry Pi.** |
- | The Raspberry Pi family and Ubuntu | + | Dans cette série d' |
+ | |||
+ | Dans l' | ||
+ | |||
+ | **The Raspberry Pi family and Ubuntu | ||
The Raspberry Pi family of single-board computers is gaining popularity as an inexpensive means of learning more about computers, about electronics, | The Raspberry Pi family of single-board computers is gaining popularity as an inexpensive means of learning more about computers, about electronics, | ||
- | The Raspberry Pi family is actually based on two different series of processors: the RPi versions A, B, and B+ have a Broadcom System-on-a-Chip (SOC) based on the ARMv6 architecture, | + | The Raspberry Pi family is actually based on two different series of processors: the RPi versions A, B, and B+ have a Broadcom System-on-a-Chip (SOC) based on the ARMv6 architecture, |
+ | |||
+ | La famille Raspberry Pi et Ubuntu | ||
+ | |||
+ | La famille d' | ||
+ | |||
+ | La famille Raspberry Pi est, en fait, basée sur deux types différents de processeurs : les versions A, B et B+ du RPi ont un SOC (System-on-Chip - système sur une puce) Broadcom sur une architecture ARMv6, alors que les modèles RPi 2 et RPi 3 sont basés sur une architecture ARMv7. Ceci a des conséquences pour le système d' | ||
+ | |||
+ | **On the other hand, for the earlier ARMv6 versions of the RPi, we will need to get a Debian (Raspbian) image. Raspbian is a very acceptable alternative for Ubuntu Server, with only two major differences. The first one is the default user (login name: pi / password: raspberry) instead of Ubuntu’s (ubuntu/ | ||
+ | |||
+ | However, for both versions, we find clues to indicate that the main target of the Free Pascal project is, indeed, the Intel 32-bit architecture. A few of the libraries do not seem to have been carried over correctly to the ARM build. For our project, the only one of note is the XMLReader unit, so we will not be able to implement the RSS reader, while the other libraries (Free Vision, Database and CURL) seem to work correctly. This would no doubt be a minor inconvenience, | ||
- | On the other hand, for the earlier ARMv6 versions | + | D'un autre côté, pour les versions |
- | However, for both versions, | + | Cependant, pour les deux versions, |
- | In any case, it may be worth noting that programs compiled for the Intel 32- or 64-bit architectures will not work directly on an RPi, since the processor architecture is different and the machine language instruction sets are not compatible. This means a re-compile will be required. There are two techniques to do so. | + | **In any case, it may be worth noting that programs compiled for the Intel 32- or 64-bit architectures will not work directly on an RPi, since the processor architecture is different and the machine language instruction sets are not compatible. This means a re-compile will be required. There are two techniques to do so. |
• The first is to install the Free Pascal compiler on the target RPi, then simply transfer our Pascal source code files over. They are recompiled on the RPi itself. Once done, the binary files (executable programs) may be copied over to and used directly on further RPis, since they are now binary-compatible with the ARM processor. | • The first is to install the Free Pascal compiler on the target RPi, then simply transfer our Pascal source code files over. They are recompiled on the RPi itself. Once done, the binary files (executable programs) may be copied over to and used directly on further RPis, since they are now binary-compatible with the ARM processor. | ||
• A second technique may be of interest when compiling applications for a very low-powered platform. Known as cross-compiling, | • A second technique may be of interest when compiling applications for a very low-powered platform. Known as cross-compiling, | ||
- | Since the RPi has sufficient power to compile its own programs on-board without being too slow about it, I would suggest readers go this route and avoid delving into cross-compiling. | + | Since the RPi has sufficient power to compile its own programs on-board without being too slow about it, I would suggest readers go this route and avoid delving into cross-compiling.** |
- | Using the Raspberry Pi directly | + | De toute façon, il vaut mieux garder en tête que les programmes compilés pour les architectures 32- et 64-bit d' |
+ | • La première consiste à installer le compilateur Free Pascal sur le RPi cible, puis à simplement transférer dessus nos fichiers source en Pascal. Ils sont recompilés par le RPi lui-même. Une fois terminé, les fichiers binaires (les programmes exécutables) peuvent être copiés et utilisés directement sur d' | ||
+ | • Une seconde technique peut présenter de l' | ||
+ | |||
+ | Comme le RPi est assez puissant pour compiler lui-même ses propres programmes sans être trop lent, je suggère aux lecteurs de suivre cette solution et d' | ||
+ | |||
+ | **Using the Raspberry Pi directly | ||
All generations of the RPi have an output to connect a screen, analog composite video (yellow RCA jack) for versions A and B, and HDMI for all. There is also at least one USB port to connect an external keyboard, so nothing more is needed to use an RPi as a terminal to run a Free Vision program. | All generations of the RPi have an output to connect a screen, analog composite video (yellow RCA jack) for versions A and B, and HDMI for all. There is also at least one USB port to connect an external keyboard, so nothing more is needed to use an RPi as a terminal to run a Free Vision program. | ||
Ligne 27: | Ligne 47: | ||
Applications are quite responsive, even on an earlier B model. The RPi’s 512 MBytes of RAM should not be overtaxed, though this will depend on the actual data usage of our program - here, I was getting by on less than 90 MBytes for the operating system and the application altogether. On the other hand, the screen image over an analog feed, while working, is not too satisfactory. HDMI should be preferred if at all possible, even if we are working just with a text console. | Applications are quite responsive, even on an earlier B model. The RPi’s 512 MBytes of RAM should not be overtaxed, though this will depend on the actual data usage of our program - here, I was getting by on less than 90 MBytes for the operating system and the application altogether. On the other hand, the screen image over an analog feed, while working, is not too satisfactory. HDMI should be preferred if at all possible, even if we are working just with a text console. | ||
- | Depending on the foreseen use of the device, a user could even be automatically logged into the console, and the Free Vision application launched immediately upon login. | + | Depending on the foreseen use of the device, a user could even be automatically logged into the console, and the Free Vision application launched immediately upon login.** |
- | The Raspberry as an application server | + | Utiliser directement le Raspberry Pi |
+ | |||
+ | Toutes les générations du Raspberry Pi ont une sortie pour connecter un écran, une sortie vidéo composite (le jack jaune RCA) pour les versions A et B, et une HDMI sur tous. Il y a aussi un port USB pour connecter un clavier externe ; ainsi, rien de plus n'est nécessaire pour utiliser un RPi comme terminal pour faire tourner un programme Free Vision. | ||
+ | |||
+ | L' | ||
+ | |||
+ | Les applications sont assez réactives, même sur un vieux modèle B. Les 512 Mo de RAM du RPi ne sont pas surchargées, | ||
+ | |||
+ | Suivant l' | ||
+ | |||
+ | **The Raspberry as an application server | ||
One of the nicer characteristics of Free Vision applications is that they work well over an SSH connection. Since our RPi already comes with an SSH server (both in Ubuntu Server and in Raspbian), it can immediately become an application server by simply installing our application’s binary file in the user’s home directory. One can then SSH over from one’s preferred computing device such as a computer or a tablet, and access the application. The low network overhead also helps application responsivity. | One of the nicer characteristics of Free Vision applications is that they work well over an SSH connection. Since our RPi already comes with an SSH server (both in Ubuntu Server and in Raspbian), it can immediately become an application server by simply installing our application’s binary file in the user’s home directory. One can then SSH over from one’s preferred computing device such as a computer or a tablet, and access the application. The low network overhead also helps application responsivity. | ||
The Raspberry Pi 3 allows us to go one step further, and avoid the need for a physical network connection through the use of the inbuilt WiFi adaptor. To set this up from the command line, we cannot depend on Network Manager that may be familiar to Ubuntu desktop users. Instead, we will need to install wpa-supplicant by hand - since we are all using WPA encryption by default on our networks, are we not? So: | The Raspberry Pi 3 allows us to go one step further, and avoid the need for a physical network connection through the use of the inbuilt WiFi adaptor. To set this up from the command line, we cannot depend on Network Manager that may be familiar to Ubuntu desktop users. Instead, we will need to install wpa-supplicant by hand - since we are all using WPA encryption by default on our networks, are we not? So: | ||
+ | |||
+ | apt install wpasupplicant** | ||
+ | |||
+ | Le Raspberry Pi comme serveur d' | ||
+ | |||
+ | Une des belles caractéristiques des applications Free Vision est qu' | ||
+ | |||
+ | Le Raspberry Pi nous permet d' | ||
apt install wpasupplicant | apt install wpasupplicant | ||
- | Now, we need to create a hash of our WiFi’s WPA key: | + | **Now, we need to create a hash of our WiFi’s WPA key: |
wpa_passphrase essid key | wpa_passphrase essid key | ||
Ligne 57: | Ligne 95: | ||
wpa-psk 407c7d4b572bf701afc06ddd6886cf33ce4f4f2e924d7f12cebe54628d74013e | wpa-psk 407c7d4b572bf701afc06ddd6886cf33ce4f4f2e924d7f12cebe54628d74013e | ||
- | naturally, replacing these values with your own as appropriate. | + | naturally, replacing these values with your own as appropriate.** |
- | The final installation is rather minimal, consisting just of the RPi 3 itself, micro-SD card and a telephone charger for power. It can be placed in a suitable location, but please do make sure it has sufficient ventilation since the more powerful processor on this model can have issues with overheating. | + | Maintenant, nous devons créer un hachage de notre clé WPA du WiFi : |
+ | |||
+ | wpa_passphrase essid key | ||
+ | |||
+ | où « essid » devra être remplacé par l' | ||
+ | |||
+ | # wpa_passphrase myessid 12345678 | ||
+ | network={ | ||
+ | ssid=" | ||
+ | # | ||
+ | psk=407c7d4b572bf701afc06ddd6886cf33ce4f4f2e924d7f12cebe54628d74013e | ||
+ | } | ||
+ | |||
+ | Nous pouvons maintenant éditer le fichier / | ||
+ | |||
+ | auto wlan0 | ||
+ | iface wlan0 inet dhcp | ||
+ | wpa-ssid myessid | ||
+ | wpa-psk 407c7d4b572bf701afc06ddd6886cf33ce4f4f2e924d7f12cebe54628d74013e | ||
+ | |||
+ | en remplaçant, | ||
+ | |||
+ | **The final installation is rather minimal, consisting just of the RPi 3 itself, micro-SD card and a telephone charger for power. It can be placed in a suitable location, but please do make sure it has sufficient ventilation since the more powerful processor on this model can have issues with overheating. | ||
Such a setup would be sufficient for light database work, such as entering a sale or a bill of lading in a business, or data entry on the move for a scientific application. The data entered can then be transferred periodically to a larger computer and be integrated into its database. If large data handling capacities are needed, the RPi can still work as a front end, but the data repository will need to be moved to a separate database system and accessed over the network. | Such a setup would be sufficient for light database work, such as entering a sale or a bill of lading in a business, or data entry on the move for a scientific application. The data entered can then be transferred periodically to a larger computer and be integrated into its database. If large data handling capacities are needed, the RPi can still work as a front end, but the data repository will need to be moved to a separate database system and accessed over the network. | ||
- | In this part of our series on using Free Pascal with Ubuntu, we saw various ways in which our application can run on a Raspberry Pi, turning it either into a lightweight terminal or an equally lightweight application server. In the next part, we will focus on what makes the Raspberry Pi unique, and will build a Free Vision interface to make use of the General Purpose I/O ports on this small board computer. | + | In this part of our series on using Free Pascal with Ubuntu, we saw various ways in which our application can run on a Raspberry Pi, turning it either into a lightweight terminal or an equally lightweight application server. In the next part, we will focus on what makes the Raspberry Pi unique, and will build a Free Vision interface to make use of the General Purpose I/O ports on this small board computer.** |
+ | |||
+ | L' | ||
+ | |||
+ | Un tel paramétrage peut être suffisant pour le travail avec une base de données légère, telle que la saisie d'une vente ou un connaissement dans une entreprise, ou des saisies de données à la volée pour une application scientifique. Les données entrées peuvent ensuite être transférées périodiquement vers un plus gros ordinateur et intégrées dans sa base. Si un besoin de gestion d'une grande quantité de données est nécessaire, | ||
+ | |||
+ | Dans cette partie de la série sur l' | ||
+ | façons de faire tourner notre application sur un Raspberry Pi, le transformant, |
issue116/tuto2.1483368111.txt.gz · Dernière modification : 2017/01/02 15:41 de auntiee