Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Built-in control system based on Linux

Status
Not open for further replies.

Vermes

Advanced Member level 4
Joined
Aug 2, 2011
Messages
1,163
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,316
Activity points
22,318


It is a fail-safe, efficient control system of any electrical device. The control is via Internet website and uses only what is provided by the operational system without any additional software or hardware drivers. Communication with external actuating device is implemented via port COM1 of the computer. Executive part of the device is a driver based on AVR microcontroller. Relays provide switching on and off.

Software:
The project requires appropriate software for work.
Linux tasks:
  • facilitate php and http services
  • stable cooperate with a number of different hardware configurations on which it will be installed
  • control over the actuating device should be implemented without any special drivers
  • control should be convenient and simple

To fulfill these assumptions, you should choose the proper distribution of Linux. To ensure stability and long fail-safe operation, the system must be run in RAM. The system cannot make any saving on hard drive. In this particular case, additional assumptions are:
  • small size of the device
  • supply from a simple accumulator 12V
  • very low current consumption

In order to fulfill these assumptions, you have to use mini ITX board, special power supply (ATX<->12V), adapter IDE <->CF and memory card CF.
The choice was PuppyLinux – distribution for computers with a small amount of RAM and adapted to work with Flash Memory – which is very important for long and fail-safe operation. Nowadays, SSDs are expensive and all the memory cards on the market have a limited number of guaranteed entries to about 200 thousand.
That restriction should be taken seriously – during normal work, different kinds of memory cards are not used so intense and the number of 200 thousand entries is not available in a read time of using the card. Unfortunately, the operational system can use this number of entries in a short time, for such as buffering the actions made in RAM on the disk.
In its assumptions, Linux has a special SWAP partition. However, this partition can not be created in the system with electronic disk. Note that even the SSDs are equipped with guaranteed number of entries, but internal software of the disk evenly distributes entries in memories, so that you do not know that at intensive using the disk by the system – the disk can be damaged.
System should be uploaded according to the installer instructions.
After installation, you should upload all the necessary software: php and SQL server by downloading a file mysql-5.0.67_php-5.2.6-1.1-i486pet from the Internet.

php scripts:
Internet website controls the actuating devices through function php exec().
First thing you have to do while carrying out this project is to determine the way of operation of this command in Linux.
Sample php code describing this function:
Code:
<?php*
Echo exec(‘whoami’);*
?>

This function in Linux determines the user from which the www server is activated, returning the user name to the website.
It makes it such as a user entering commands in the console.
In this case, the function returns the name _nobody_ - which is consistent with safety trend in Linux.
In most cases the user do not have rights to perform any actions on the system files and basic commands of the console, what causes a small problem – all the commands which have to be implemented by the php code in the system, are not available for the user of the code.
php code 101
Code:
<?php*
Echo exec(‘whoami’);*
Echo exec(‘stty –F /dev/ttyS0 9600 –ixoff icrnl ixon opost isig icanon iexten echo echoe echok echoctl echoke’);*
Echo exec(‘ echo ‘’##’’ > /dev/ttyS0’);*
?>

The above code will not be implemented, because:
  • you do not have the possibility to use stty
  • you cannot save anything to the device /dev/ttyS0
  • you cannot use the echo

If you check in the console, who can use for example stty, by means of ls -i /bin/stty, you will receive information that the owner of the file and the only person who can perform this file is root. The rest commands will have the same situation, so that you have to:

  • assign these files to the user _nobody_
  • allow everyone to perform these files

These can be done by chmod and chgrp:
Code:
Chgrp _nobody_ /bin/echo –h

(mark -h is added to the function echo due to the fact that it is symlink for busybox, you can learn that by performing ls -l/bin/echo, as usually standard _posix_ does not respond how the function echo is to work)

Code:
Chgrp _nobody_ /bin/stty –h*
Chgrp _nobody_ /bin/busybox*
Chgrp _nobody_ /dev/ttyS0

And the executability issue:

Code:
Chmod 777 /bin/echo*
Chmod 777 /bin/stty*
Chmod 777 /bin/busybox*
Chmod 777 /dev/ttyS0

So that for efficient cooperation of php with the system, add these commands to the script which is performed at every start of the system – rc.local file in catalog /etc/rc.d is such a script.

Link to original thread (useful attachment) - System wbudowanego sterowania oparty na Linux.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top