Service doen't start on Raspbian Linux Raspberry Pi 2 model B with LCD module

Internet of Things IoT Frameworks 2 years ago

0 0 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ I have Raspberry Pi 2 model B with installed Raspbian Linux. I have to create and start linux service which prints text on LCD Module SC1602a. It looks like this: [] I create my daemon service using Java language 1.8_x86 , Apache Commons Daemon and jsvc. Also I use pi4j project (this is wrapper over WiringPi) to manage Raspberry Pi pins. Java class: public class Application implements Daemon{ public static void main(String[] a){ Application app=new Application(); app.init(null); app.start(); System.in.read(); application.stop(); application.destroy(); } public void init(DaemonContext daemonContext) throws Exception { LogUtil.info("Init method..."); GpioController gpio = GpioFactory.getInstance(); LogUtil.info("GpioController instance created..."); GpioLcdDisplay lcd; lcd = new GpioLcdDisplay(2, 16, RaspiPin.GPIO_00, RaspiPin.GPIO_02, new Pin[]{RaspiPin.GPIO_03, RaspiPin.GPIO_04, RaspiPin.GPIO_05, RaspiPin.GPIO_06}); LogUtil.info("LCD instance created..."); lcd.clear(); lcd.write(new Date().toString()); LogUtil.info("Init compeleted:"); } public void start() throws Exception {} public void stop() throws Exception {} public void destroy() {} } I use maven to package my artifact. I Use WinScp to move artifact to Raspberry Pi. When I start this application from command line java -jar application.jar it works well. Application print to LCD module "hello" string. Next I tried to start my application like linux service. I installed jsvc on Raspberry Pi, created script lcd and moved it to folder /etc/init.d/ . Also I wrote chmod +x lcd from folder /etc/init.d. This is my script: NAME="lcd" DESC="Lcd Application" EXEC="/usr/bin/jsvc" FILE_PATH="/root/lcd" JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt CLASS_PATH="$FILE_PATH/lcd.jar:/usr/share/java/commons-daemon-1.0.15.jar" CLASS="com.mycompany.Application" ARGS="" USER="root" PID="/var/run/$NAME.pid" LOG_OUT="$FILE_PATH/$NAME.out" LOG_ERR="$FILE_PATH/$NAME.err" jsvc_exec() { cd $FILE_PATH echo $CLASS_PATH sudo $EXEC -home $JAVA_HOME -cp $CLASS_PATH -user $USER -outfile $LOG_OUT -errfile $LOG_ERR -pidfile $PID $1 $CLASS $ARGS } case "$1" in start) echo "Starting service LCD" jsvc_exec echo "Service started" ;; //many unimportant information I write command service lcd start. This way doesn't work. In this case application doesn't print on LCD module any information. I opened log files and found next information: lcd.out: 2015-08-20 12:59:09.934 [INFO] - Init method... lcd.err: wiringPiSetup: Unable to open /dev/mem: Operation not permitted Service exit with a return value of 1 As you can see application fails when trying to load pi4j driver. I tried to extend access rules for dev/mem file, I did it and file has rwxrwxrwx but service still not working. Also I turned off LCD initialization from init() method. Service starts well so service works well without LCD. Does anybody know the solution? Thanks a lot

Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (0)

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Internet of Things Links