From d9d92203ea349d5eb44c0edc5565d827322caabe Mon Sep 17 00:00:00 2001 From: Jorawar Singh Date: Sun, 16 Jul 2017 22:17:43 +0530 Subject: Toolbox merge, RPI demos and structured demos --- .../Hardware/RasberryPi/Setup/RPI_pinNumbering.sci | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci (limited to 'macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci') diff --git a/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci b/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci new file mode 100755 index 0000000..4716de8 --- /dev/null +++ b/macros/Hardware/RasberryPi/Setup/RPI_pinNumbering.sci @@ -0,0 +1,54 @@ +// Copyright (C) 2017 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function out=RPI_pinNumbering(pinSetup) +// Function to initialize wiringpi with the number sequence to be followed. +// +// Calling Sequence +// RPI_pinNumbering(pinSetup) +// +// Parameters +// pinSetup: The pin number sequence to follow +// +// Description +// This function must be called at the start of the program or the program will fail to work correctly. It tells the wiringpi which number sequence will be used to work on Raspberry Pi. Returns 0 if no errors encountered. Pin maps for the different pinSetups can be found at the link in bibliography. +// +// pinSetup can take the following values: +// +// 'wiringpi' -> This initialises wiringPi and assumes that the calling program is going to be using the wiringPi pin numbering scheme. This is a simplified numbering scheme which provides a mapping from virtual pin numbers to the real underlying Broadcom GPIO pin numbers. +// 'GPIO' -> Same as above, however it allows the calling programs to use the Broadcom GPIO pin numbers directly with no re-mapping. +// 'phys' -> Identical to above, however it allows the calling programs to use the physical pin numbers on the P1 connector only. +// +// +// Examples +// RPI_pinNumbering('wiringpi') +// Authors +// Jorawar Singh +// +// Bibliography +// http://wiringpi.com/reference/ + + if (pinSetup=='wiringpi') then + commande="pN0#0#"; + elseif (pinSetup=='GPIO') then + commande="pN1#0#"; + elseif (pinSetup=='sys') then + commande="pN2#0#"; + elseif (pinSetup=='phys') then + commande="pN3#0#"; + else + error("pinSetup should be one of wiringpi/GPIO/sys/phys"); + end + if getos()=="Linux" then + out=unix_g("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + elseif getos()=="Windows" then + [out,RPI_winR]=dos("python -c ""import socket;s=socket.socket();s.connect((''"+RPI_piAdress+"'',9077));s.send(''"+commande+"'');print(s.recv(1024));s.close()"""); + end +endfunction -- cgit