From fe8c2806cdba70479e351299881a395dc2be7785 Mon Sep 17 00:00:00 2001 From: wdenk Date: Sun, 3 Nov 2002 00:38:21 +0000 Subject: Initial revision --- tools/bddb/README | 116 ++++++++ tools/bddb/brlog.php | 106 +++++++ tools/bddb/browse.php | 130 +++++++++ tools/bddb/config.php | 16 ++ tools/bddb/create_tables.sql | 90 ++++++ tools/bddb/defs.php | 663 +++++++++++++++++++++++++++++++++++++++++++ tools/bddb/dodelete.php | 64 +++++ tools/bddb/dodellog.php | 55 ++++ tools/bddb/doedit.php | 170 +++++++++++ tools/bddb/doedlog.php | 66 +++++ tools/bddb/donew.php | 228 +++++++++++++++ tools/bddb/donewlog.php | 76 +++++ tools/bddb/edit.php | 131 +++++++++ tools/bddb/edlog.php | 81 ++++++ tools/bddb/execute.php | 37 +++ tools/bddb/index.php | 38 +++ tools/bddb/new.php | 121 ++++++++ tools/bddb/newlog.php | 48 ++++ 18 files changed, 2236 insertions(+) create mode 100644 tools/bddb/README create mode 100644 tools/bddb/brlog.php create mode 100644 tools/bddb/browse.php create mode 100644 tools/bddb/config.php create mode 100644 tools/bddb/create_tables.sql create mode 100644 tools/bddb/defs.php create mode 100644 tools/bddb/dodelete.php create mode 100644 tools/bddb/dodellog.php create mode 100644 tools/bddb/doedit.php create mode 100644 tools/bddb/doedlog.php create mode 100644 tools/bddb/donew.php create mode 100644 tools/bddb/donewlog.php create mode 100644 tools/bddb/edit.php create mode 100644 tools/bddb/edlog.php create mode 100644 tools/bddb/execute.php create mode 100644 tools/bddb/index.php create mode 100644 tools/bddb/new.php create mode 100644 tools/bddb/newlog.php (limited to 'tools/bddb') diff --git a/tools/bddb/README b/tools/bddb/README new file mode 100644 index 000000000..778e41c1d --- /dev/null +++ b/tools/bddb/README @@ -0,0 +1,116 @@ +Hymod Board Database + +(C) Copyright 2001 +Murray Jensen +CSIRO Manufacturing Science and Technology, Preston Lab + +25-Jun-01 + +This stuff is a set of PHP/MySQL scripts to implement a custom board +database. It will need *extensive* hacking to modify it to keep the +information about your custom boards that you want, however it is a good +starting point. + +How it is used: + + 1. a board has gone through all the hardware testing etc and is + ready to have the flash programmed for the first time - first you + go to a web page and fill in information about the board in a form + to register it in a database + + 2. the web stuff allocates a (unique) serial number and (optionally) + a (locally administered) ethernet address and stores the information + in a database using the serial number as the key (can do whole + batches of boards in one go and/or use a previously registered board + as defaults for the new board(s)) + + 3. it then creates a file in the tftp area of a server somewhere + containing the board information in a simple text format (one + per serial number) + + 4. all hymod boards have an i2c eeprom, and when U-Boot sees that + the eeprom is unitialised, it prompts for a serial number and + ethernet address (if not set), then transfers the file created + in step 3 from the server and initialises the eeprom from its + contents + +What this means is you can't boot the board until you have allocated a serial +number, but you don't have to type it all twice - you do it once on the web +and the board then finds the info it needs to initialise its eeprom. The +other side of the coin is the reading of the eeprom and how it gets passed +to Linux (or another O/S). + +To see how this is all done for the hymod boards look at the code in the +"board/hymod" directory and in the file "include/asm/hymod.h". Hymod boards +can have a mezzanine card which also have an eeprom that needs allocating, +the same process is used for these as well - just a different i2c address. + +Other forms provide the following functions: + + - browsing the board database + - editing board information (one at a time) + - maintaining/browsing a (simple) per board event log + +You will need: MySQL (I use version 3.23.7-alpha), PHP4 (with MySQL +support enabled) and a web server (I use Apache 1.3.x). + +I originally started by using phpMyBuilder (http://kyber.dk/phpMyBuilder) +but it soon got far more complicated than that could handle (but I left +the copyright messages in there anyway). Most of the code resides in the +common defs.php file, which shouldn't need much alteration - all the work +will be in shaping the front-end php files to your liking. + +Here's a quick summary of what needs doing to use it for your boards: + +1. get phpMyAdmin (http://phpwizard.net/projects/phpMyAdmin/) - it's an + invaluable tool for this sort of stuff (this step is optional of course) + +2. edit "bddb.css" to your taste, if you could be bothered - I have no + idea what is in there or what it does - I copied it from somewhere else + ("user.css" from the phpMyEdit (http://phpmyedit.sourcerforge.net) package, + I think) - I figure one day I'll see what sort of things I can change + in there. + +3. create a mysql database - call it whatever you like + +4. edit "create_tables.sql" and modify the "boards" table schema to + reflect the information you want to keep about your boards. It may or + may not be easier to do this and the next step in phpMyAdmin. Check out + the MySQL documentation at http://www.mysql.com/doc/ in particular the + column types at http://www.mysql.com/doc/C/o/Column_types.html - Note + there is only support for a few data types: + + int - presented as an html text input + char/text - presented as an html text input + date - presented as an html text input + enum - presented as an html radio input + + I also have what I call "enum_multi" which is a set of enums with the + same name, but suffixed with a number e.g. fred0, fred1, fred2. These + are presented as a number of html select's with a single label "fred" + this is useful for board characteristics that have multiple items of + the same type e.g. multiple banks of sdram. + +5. use the "create_tables.sql" file to create the "boards" table in the + database e.g. mysql dbname < create_tables.sql + +6. create a user and password for the web server to log into the MySQL + database with; give this user select, insert and update privileges + to the database created in 3 (and delete, if you want the "delete" + functions in the edit forms to work- I have this turned off). phpMyAdmin + helps in this step. + +7. edit "config.php" and set the variables: $mysql_user, $mysql_pw, $mysql_db, + $bddb_cfgdir and $bddb_label - keep the contents of this file secret - it + contains the web servers username and password (the three $mysql_* vars + are set from the previous step) + +8. edit "defs.php" and a. adjust the various enum value arrays and b. edit + the function "pg_foot()" to remove my email address :-) + +9. do major hacking on the following files: browse.php, doedit.php, donew.php, + edit.php and new.php to reflect your database schema - fortunately the + hacking is fairly straight-forward, but it is boring and time-consuming. + +These notes were written rather hastily - if you find any obvious problems +please let me know. diff --git a/tools/bddb/brlog.php b/tools/bddb/brlog.php new file mode 100644 index 000000000..6e98c9c48 --- /dev/null +++ b/tools/bddb/brlog.php @@ -0,0 +1,106 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // list page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Browse Board Log"); + + if (!isset($serno) || $serno == 0) + die("serial number not specified!"); + + function print_cell($str) { + if ($str == '') + $str = ' '; + echo "\t$str\n"; + } +?> + + + + + + + + + + +\n"; + print_cell("$row[serno]"); + print_cell($row['ethaddr']); + print_cell($row['date']); + print_cell($row['batch']); + print_cell($row['type']); + print_cell($row['rev']); + print_cell($row['location']); + echo "\n"; + } + + mysql_free_result($r); +?> +
serno / editethaddrdatebatchtyperevlocation
+
+

+$limit){ + $preoffset=max(0,$offset-$limit); + $postoffset=$offset+$limit; + echo "\n\n"; + printf("\n", $offset>0?"":"no", $PHP_SELF, $preoffset); + printf("\n", $postoffset<$lrow['n']?"":"no", $PHP_SELF, $postoffset); + echo "\n
<%sa href=\"%s?serno=$serno&offset=%d\">\"<\"<%sa href=\"%s?serno=$serno&offset=%d\">\">\"
\n"; + } + mysql_free_result($lr); +?> + + + + + + +\n"; + print_cell("$row[logno]"); + print_cell($row['date']); + print_cell("
" . urldecode($row['details']) . "
"); + echo "\n"; + } + + mysql_free_result($r); +?> +
logno / editdatedetails
+
+

+ + + + + +
+ ">Add to Log + + Back to Start +
+ diff --git a/tools/bddb/browse.php b/tools/bddb/browse.php new file mode 100644 index 000000000..b7cd50895 --- /dev/null +++ b/tools/bddb/browse.php @@ -0,0 +1,130 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // list page (hymod_bddb / boards) + + require("defs.php"); + + if (!isset($verbose)) + $verbose = 0; + + if (!isset($serno)) + $serno = 0; + + pg_head("$bddb_label - Browse database" . ($verbose?" (verbose)":"")); +?> +

+$limit){ + $preoffset=max(0,$offset-$limit); + $postoffset=$offset+$limit; + echo "\n\n"; + printf("\n", $offset>0?"":"no", $PHP_SELF, $preoffset); + printf("\n", $postoffset<$lrow['n']?"":"no", $PHP_SELF, $postoffset); + echo "\n
<%sa href=\"%s?offset=%d\">\"<\"<%sa href=\"%s?offset=%d\">\">\"
\n"; + } + mysql_free_result($lr); + } +?> + + + + + + + + + + +comments\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } +?> + +$str\n"; + } + + while($row=mysql_fetch_array($r)){ + foreach ($columns as $key) { + if (!key_in_array($key, $row)) + $row[$key] = ''; + } + + echo "\n"; + print_cell("Log"); + print_cell("$row[serno]"); + print_cell($row['ethaddr']); + print_cell($row['date']); + print_cell($row['batch']); + print_cell($row['type']); + print_cell($row['rev']); + print_cell($row['location']); + if ($verbose) { + print_cell("
\n" . urldecode($row['comments']) .
+				"\n\t
"); + print_cell(gather_enum_multi_print("sdram", 4, $row)); + print_cell(gather_enum_multi_print("flash", 4, $row)); + print_cell(gather_enum_multi_print("zbt", 16, $row)); + print_cell(gather_enum_multi_print("xlxtyp", 4, $row)); + print_cell(gather_enum_multi_print("xlxspd", 4, $row)); + print_cell(gather_enum_multi_print("xlxtmp", 4, $row)); + print_cell(gather_enum_multi_print("xlxgrd", 4, $row)); + print_cell($row['cputyp']); + print_cell($row['cpuspd']); + print_cell($row['cpmspd']); + print_cell($row['busspd']); + print_cell($row['hstype']); + print_cell($row['hschin']); + print_cell($row['hschout']); + } + echo "\n"; + } +?> +
serno / editethaddrdatebatchtyperevlocationsdramflashzbtxlxtypxlxspdxlxtmpxlxgrdcputypcpuspdcpmspdbusspdhstypehschinhschout
+

+ + + + + +
Terse Listing"; + else + echo "Verbose Listing"; + ?>Back to Start
+ diff --git a/tools/bddb/config.php b/tools/bddb/config.php new file mode 100644 index 000000000..8d54993c5 --- /dev/null +++ b/tools/bddb/config.php @@ -0,0 +1,16 @@ + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // mysql database access info + $mysql_user="fred"; + $mysql_pw="apassword"; + $mysql_db="mydbname"; + + // where to put the eeprom config files + $bddb_cfgdir = '/tftpboot/bddb'; + + // what this database is called + $bddb_label = 'Hymod Board Database'; +?> diff --git a/tools/bddb/create_tables.sql b/tools/bddb/create_tables.sql new file mode 100644 index 000000000..aa007c16c --- /dev/null +++ b/tools/bddb/create_tables.sql @@ -0,0 +1,90 @@ +# phpMyAdmin MySQL-Dump +# http://phpwizard.net/phpMyAdmin/ +# +# Host: localhost Database : hymod_bddb + +# (C) Copyright 2001 +# Murray Jensen +# CSIRO Manufacturing Science and Technology, Preston Lab + +# -------------------------------------------------------- +# +# Table structure for table 'boards' +# + +DROP TABLE IF EXISTS boards; +CREATE TABLE boards ( + serno int(10) unsigned zerofill NOT NULL auto_increment, + ethaddr char(17), + date date NOT NULL, + batch char(32), + type enum('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY') NOT NULL, + rev tinyint(3) unsigned zerofill NOT NULL, + location char(64), + comments text, + sdram0 enum('32M','64M','128M','256M'), + sdram1 enum('32M','64M','128M','256M'), + sdram2 enum('32M','64M','128M','256M'), + sdram3 enum('32M','64M','128M','256M'), + flash0 enum('4M','8M','16M','32M','64M'), + flash1 enum('4M','8M','16M','32M','64M'), + flash2 enum('4M','8M','16M','32M','64M'), + flash3 enum('4M','8M','16M','32M','64M'), + zbt0 enum('512K','1M','2M','4M'), + zbt1 enum('512K','1M','2M','4M'), + zbt2 enum('512K','1M','2M','4M'), + zbt3 enum('512K','1M','2M','4M'), + zbt4 enum('512K','1M','2M','4M'), + zbt5 enum('512K','1M','2M','4M'), + zbt6 enum('512K','1M','2M','4M'), + zbt7 enum('512K','1M','2M','4M'), + zbt8 enum('512K','1M','2M','4M'), + zbt9 enum('512K','1M','2M','4M'), + zbta enum('512K','1M','2M','4M'), + zbtb enum('512K','1M','2M','4M'), + zbtc enum('512K','1M','2M','4M'), + zbtd enum('512K','1M','2M','4M'), + zbte enum('512K','1M','2M','4M'), + zbtf enum('512K','1M','2M','4M'), + xlxtyp0 enum('XCV300E','XCV400E','XCV600E'), + xlxtyp1 enum('XCV300E','XCV400E','XCV600E'), + xlxtyp2 enum('XCV300E','XCV400E','XCV600E'), + xlxtyp3 enum('XCV300E','XCV400E','XCV600E'), + xlxspd0 enum('6','7','8'), + xlxspd1 enum('6','7','8'), + xlxspd2 enum('6','7','8'), + xlxspd3 enum('6','7','8'), + xlxtmp0 enum('COM','IND'), + xlxtmp1 enum('COM','IND'), + xlxtmp2 enum('COM','IND'), + xlxtmp3 enum('COM','IND'), + xlxgrd0 enum('NORMAL','ENGSAMP'), + xlxgrd1 enum('NORMAL','ENGSAMP'), + xlxgrd2 enum('NORMAL','ENGSAMP'), + xlxgrd3 enum('NORMAL','ENGSAMP'), + cputyp enum('MPC8260'), + cpuspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'), + cpmspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'), + busspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'), + hstype enum('AMCC-S2064A'), + hschin enum('0','1','2','3','4'), + hschout enum('0','1','2','3','4'), + PRIMARY KEY (serno), + KEY serno (serno), + UNIQUE serno_2 (serno) +); + +# +# Table structure for table 'log' +# + +DROP TABLE IF EXISTS log; +CREATE TABLE log ( + logno int(10) unsigned zerofill NOT NULL auto_increment, + serno int(10) unsigned zerofill NOT NULL, + date date NOT NULL, + details text NOT NULL, + PRIMARY KEY (logno), + KEY logno (logno, serno, date), + UNIQUE logno_2 (logno) +); diff --git a/tools/bddb/defs.php b/tools/bddb/defs.php new file mode 100644 index 000000000..0393dbda6 --- /dev/null +++ b/tools/bddb/defs.php @@ -0,0 +1,663 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // contains mysql user id and password - keep secret + require("config.php"); + + if (isset($logout)) { + Header("status: 401 Unauthorized"); + Header("HTTP/1.0 401 Unauthorized"); + Header("WWW-authenticate: basic realm=\"$bddb_label\""); + + echo "" . + "Access to '$bddb_label' Denied" . + "\n"; + echo "



" . + "You must be an Authorised User " . + "to access the '$bddb_label'" . + "

\n
\n"; + exit; + } + + // contents of the various enumerated types - if first item is + // empty ('') then the enum is allowed to be null (ie "not null" + // is not set on the column) + + // all column names in the database table + $columns = array( + 'serno','ethaddr','date','batch', + 'type','rev','location','comments', + 'sdram0','sdram1','sdram2','sdram3', + 'flash0','flash1','flash2','flash3', + 'zbt0','zbt1','zbt2','zbt3','zbt4','zbt5','zbt6','zbt7', + 'zbt8','zbt9','zbta','zbtb','zbtc','zbtd','zbte','zbtf', + 'xlxtyp0','xlxtyp1','xlxtyp2','xlxtyp3', + 'xlxspd0','xlxspd1','xlxspd2','xlxspd3', + 'xlxtmp0','xlxtmp1','xlxtmp2','xlxtmp3', + 'xlxgrd0','xlxgrd1','xlxgrd2','xlxgrd3', + 'cputyp','cpuspd','cpmspd','busspd', + 'hstype','hschin','hschout' + ); + + // board type + $type_vals = array('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY'); + + // sdram sizes (nbits array is for write into eeprom config file) + $sdram_vals = array('','32M','64M','128M','256M'); + $sdram_nbits = array(0,25,26,27,28); + + // flash sizes (nbits array is for write into eeprom config file) + $flash_vals = array('','4M','8M','16M','32M','64M'); + $flash_nbits = array(0,22,23,24,25,26); + + // zbt ram sizes (nbits array is for write into eeprom config file) + $zbt_vals = array('','512K','1M','2M','4M'); + $zbt_nbits = array(0,19,20,21,22); + + // Xilinx attributes + $xlxtyp_vals = array('','XCV300E','XCV400E','XCV600E'); + $xlxspd_vals = array('','6','7','8'); + $xlxtmp_vals = array('','COM','IND'); + $xlxgrd_vals = array('','NORMAL','ENGSAMP'); + + // processor attributes + $cputyp_vals = array('','MPC8260'); + $clk_vals = array('','33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ'); + + // high-speed serial attributes + $hstype_vals = array('','AMCC-S2064A'); + $hschin_vals = array('0','1','2','3','4'); + $hschout_vals = array('0','1','2','3','4'); + + // value filters - used when outputting html + function rev_filter($num) { + if ($num == 0) + return "001"; + else + return sprintf("%03d", $num); + } + + function text_filter($str) { + return urldecode($str); + } + + mt_srand(time() | getmypid()); + + // set up MySQL connection + mysql_connect("", $mysql_user, $mysql_pw) || die("cannot connect"); + mysql_select_db($mysql_db) || die("cannot select db"); + + // page header + function pg_head($title) + { + echo "\n\n"; + echo "\n"; + echo "$title\n"; + echo "\n"; + echo "\n"; + echo "

$title

\n"; + echo "
\n"; + } + + // page footer + function pg_foot() + { + echo "
\n"; + echo "
\n
" . + "If you have any problems, email " . + "" . + "Murray Jensen" . + "
\n" . + "
\n" . + "logout\n" . + "
\n"; + echo "

Made with " . + "" . + "Kyber phpMyBuilder

\n"; + echo "\n"; + echo "\n"; + } + + // some support functions + + if (!function_exists('array_search')) { + + function array_search($needle, $haystack, $strict = false) { + + if (is_array($haystack) && count($haystack)) { + + $ntype = gettype($needle); + + foreach ($haystack as $key => $value) { + + if ($value == $needle && (!$strict || + gettype($value) == $ntype)) + return $key; + } + } + + return false; + } + } + + if (!function_exists('in_array')) { + + function in_array($needle, $haystack, $strict = false) { + + if (is_array($haystack) && count($haystack)) { + + $ntype = gettype($needle); + + foreach ($haystack as $key => $value) { + + if ($value == $needle && (!$strict || + gettype($value) == $ntype)) + return true; + } + } + + return false; + } + } + + function key_in_array($key, $array) { + return in_array($key, array_keys($array), true); + } + + function enum_to_index($name, $vals) { + $index = array_search($GLOBALS[$name], $vals); + if ($vals[0] != '') + $index++; + return $index; + } + + // fetch a value from an array - return empty string is not present + function get_key_value($key, $array) { + if (key_in_array($key, $array)) + return $array[$key]; + else + return ''; + } + + function fprintf() { + $n = func_num_args(); + if ($n < 2) + return FALSE; + $a = func_get_args(); + $fp = array_shift($a); + $x = "\$s = sprintf"; + $sep = '('; + foreach ($a as $z) { + $x .= "$sep'$z'"; + $sep = ','; + } + $x .= ');'; + eval($x); + $l = strlen($s); + $r = fwrite($fp, $s, $l); + if ($r != $l) + return FALSE; + else + return TRUE; + } + + // functions to display (print) a database table and its columns + + function begin_table($ncols) { + global $table_ncols; + $table_ncols = $ncols; + echo "\n"; + } + + function begin_field($name, $span = 0) { + global $table_ncols; + echo "\n"; + echo "\t\n"; + if ($span <= 0) + $span = $table_ncols - 1; + if ($span > 1) + echo "\t\n"; + if ($span > 1) + echo "\t\n"; + echo "\n"; + } + + function end_table() { + echo "
$name\n"; + else + echo "\t\n"; + } + + function cont_field($span = 1) { + echo "\t\n"; + else + echo "\t\n"; + } + + function end_field() { + echo "\t
\n"; + } + + function print_field($name, $array, $size = 0, $filt='') { + + begin_field($name); + + if (key_in_array($name, $array)) + $value = $array[$name]; + else + $value = ''; + + if ($filt != '') + $value = $filt($value); + + echo "\t\t 0) + echo " size=$size maxlength=$size"; + echo ">\n"; + + end_field(); + } + + function print_field_multiline($name, $array, $cols, $rows, $filt='') { + + begin_field($name); + + if (key_in_array($name, $array)) + $value = $array[$name]; + else + $value = ''; + + if ($filt != '') + $value = $filt($value); + + echo "\t\t\n"; + + end_field(); + } + + // print a mysql ENUM as an html RADIO INPUT + function print_enum($name, $array, $vals, $def = -1) { + + begin_field($name); + + if (key_in_array($name, $array)) + $chk = array_search($array[$name], $vals, FALSE); + else + $chk = $def; + + $nval = count($vals); + + for ($i = 0; $i < $nval; $i++) { + + $val = $vals[$i]; + if ($val == '') + $pval = "none"; + else + $pval = "$val"; + + printf("\t\t$pval\n", + $i == $chk ? " checked" : ""); + } + + end_field(); + } + + // print a group of mysql ENUMs (e.g. name0,name1,...) as an html SELECT + function print_enum_multi($base, $array, $vals, $cnt, $defs, $grp = 0) { + + global $table_ncols; + + if ($grp <= 0) + $grp = $cnt; + $ncell = $cnt / $grp; + $span = ($table_ncols - 1) / $ncell; + + begin_field($base, $span); + + $nval = count($vals); + + for ($i = 0; $i < $cnt; $i++) { + + if ($i > 0 && ($i % $grp) == 0) + cont_field($span); + + $name = sprintf("%s%x", $base, $i); + + echo "\t\t\n"; + } + + end_field(); + } + + // functions to handle the form input + + // fetch all the parts of an "enum_multi" into a string suitable + // for a MySQL query + function gather_enum_multi_query($base, $cnt) { + + $retval = ''; + + for ($i = 0; $i < $cnt; $i++) { + + $name = sprintf("%s%x", $base, $i); + + if (isset($GLOBALS[$name])) { + $retval .= sprintf(", %s='%s'", + $name, $GLOBALS[$name]); + } + } + + return $retval; + } + + // fetch all the parts of an "enum_multi" into a string suitable + // for a display e.g. in an html table cell + function gather_enum_multi_print($base, $cnt, $array) { + + $retval = ''; + + for ($i = 0; $i < $cnt; $i++) { + + $name = sprintf("%s%x", $base, $i); + + if ($array[$name] != '') { + if ($retval != '') + $retval .= ','; + $retval .= $array[$name]; + } + } + + return $retval; + } + + // fetch all the parts of an "enum_multi" into a string suitable + // for writing to the eeprom data file + function gather_enum_multi_write($base, $cnt, $vals, $xfrm = array()) { + + $retval = ''; + + for ($i = 0; $i < $cnt; $i++) { + + $name = sprintf("%s%x", $base, $i); + + if ($GLOBALS[$name] != '') { + if ($retval != '') + $retval .= ','; + $index = enum_to_index($name, $vals); + if ($xfrm != array()) + $retval .= $xfrm[$index]; + else + $retval .= $index; + } + } + + return $retval; + } + + // count how many parts of an "enum_multi" are actually set + function count_enum_multi($base, $cnt) { + + $retval = 0; + + for ($i = 0; $i < $cnt; $i++) { + + $name = sprintf("%s%x", $base, $i); + + if (isset($GLOBALS[$name])) + $retval++; + } + + return $retval; + } + + // ethernet address functions + + // generate a (possibly not unique) random vendor ethernet address + // (setting bit 6 in the ethernet address - motorola wise i.e. bit 0 + // is the most significant bit - means it is not an assigned ethernet + // address). Also, make sure it is NOT a multicast ethernet address. + function gen_eth_addr($serno) { + + $ethaddr_high = (mt_rand(0, 65535) & 0xfeff) | 0x0200; + $ethaddr_low = mt_rand(0, 4294967295); + + return sprintf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx", + $ethaddr_high >> 8, $ethaddr_high & 0xff, + $ethaddr_low >> 24, ($ethaddr_low >> 16) & 0xff, + ($ethaddr_low >> 8) & 0xff, $ethaddr_low & 0xff); + } + + // check that an ethernet address is valid + function eth_addr_is_valid($ethaddr) { + + $ethbytes = split(':', $ethaddr); + + if (count($ethbytes) != 6) + return FALSE; + + for ($i = 0; $i < 6; $i++) { + $ethbyte = $ethbytes[$i]; + if (!ereg('^[0-9a-f][0-9a-f]$', $ethbyte)) + return FALSE; + } + + return TRUE; + } + + // write a simple eeprom configuration file + function write_eeprom_cfg_file() { + + global $sernos, $nsernos, $bddb_cfgdir, $numerrs, $cfgerrs; + global $date, $batch, $type_vals, $rev; + global $sdram_vals, $sdram_nbits; + global $flash_vals, $flash_nbits; + global $zbt_vals, $zbt_nbits; + global $xlxtyp_vals, $xlxspd_vals, $xlxtmp_vals, $xlxgrd_vals; + global $cputyp, $cputyp_vals, $clk_vals; + global $hstype, $hstype_vals, $hschin, $hschout; + + $numerrs = 0; + $cfgerrs = array(); + + for ($i = 0; $i < $nsernos; $i++) { + + $serno = sprintf("%010d", $sernos[$i]); + + $wfp = @fopen($bddb_cfgdir . "/$serno.cfg", "w"); + if (!$wfp) { + $cfgerrs[$i] = 'file create fail'; + $numerrs++; + continue; + } + set_file_buffer($wfp, 0); + + if (!fprintf($wfp, "serno=%d\n", $sernos[$i])) { + $cfgerrs[$i] = 'cfg wr fail (serno)'; + fclose($wfp); + $numerrs++; + continue; + } + + if (!fprintf($wfp, "date=%s\n", $date)) { + $cfgerrs[$i] = 'cfg wr fail (date)'; + fclose($wfp); + $numerrs++; + continue; + } + + if ($batch != '') { + if (!fprintf($wfp, "batch=%s\n", $batch)) { + $cfgerrs[$i] = 'cfg wr fail (batch)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $typei = enum_to_index("type", $type_vals); + if (!fprintf($wfp, "type=%d\n", $typei)) { + $cfgerrs[$i] = 'cfg wr fail (type)'; + fclose($wfp); + $numerrs++; + continue; + } + + if (!fprintf($wfp, "rev=%d\n", $rev)) { + $cfgerrs[$i] = 'cfg wr fail (rev)'; + fclose($wfp); + $numerrs++; + continue; + } + + $s = gather_enum_multi_write("sdram", 4, + $sdram_vals, $sdram_nbits); + if ($s != '') { + $b = fprintf($wfp, "sdram=%s\n", $s); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (sdram)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $s = gather_enum_multi_write("flash", 4, + $flash_vals, $flash_nbits); + if ($s != '') { + $b = fprintf($wfp, "flash=%s\n", $s); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (flash)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $s = gather_enum_multi_write("zbt", 16, + $zbt_vals, $zbt_nbits); + if ($s != '') { + $b = fprintf($wfp, "zbt=%s\n", $s); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (zbt)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $s = gather_enum_multi_write("xlxtyp", 4, $xlxtyp_vals); + if ($s != '') { + $b = fprintf($wfp, "xlxtyp=%s\n", $s); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (xlxtyp)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $s = gather_enum_multi_write("xlxspd", 4, $xlxspd_vals); + if ($s != '') { + $b = fprintf($wfp, "xlxspd=%s\n", $s); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (xlxspd)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $s = gather_enum_multi_write("xlxtmp", 4, $xlxtmp_vals); + if ($s != '') { + $b = fprintf($wfp, "xlxtmp=%s\n", $s); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (xlxtmp)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + $s = gather_enum_multi_write("xlxgrd", 4, $xlxgrd_vals); + if ($s != '') { + $b = fprintf($wfp, "xlxgrd=%s\n", $s); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (xlxgrd)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + if ($cputyp != '') { + $cputypi = enum_to_index("cputyp",$cputyp_vals); + $cpuspdi = enum_to_index("cpuspd", $clk_vals); + $busspdi = enum_to_index("busspd", $clk_vals); + $cpmspdi = enum_to_index("cpmspd", $clk_vals); + $b = fprintf($wfp, "cputyp=%d\ncpuspd=%d\n" . + "busspd=%d\ncpmspd=%d\n", + $cputypi, $cpuspdi, $busspdi, $cpmspdi); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (cputyp)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + if ($hstype != '') { + $hstypei = enum_to_index("hstype",$hstype_vals); + $b = fprintf($wfp, "hstype=%d\n" . + "hschin=%s\nhschout=%s\n", + $hstypei, $hschin, $hschout); + if (!$b) { + $cfgerrs[$i] = 'cfg wr fail (hstype)'; + fclose($wfp); + $numerrs++; + continue; + } + } + + if (!fclose($wfp)) { + $cfgerrs[$i] = 'file cls fail'; + $numerrs++; + } + } + + return $numerrs; + } +?> diff --git a/tools/bddb/dodelete.php b/tools/bddb/dodelete.php new file mode 100644 index 000000000..839ad8cf1 --- /dev/null +++ b/tools/bddb/dodelete.php @@ -0,0 +1,64 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // dodelete page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Delete Board Results"); + + if (!($serno=intval($serno))) + die("the board serial number was not specified"); + + mysql_query("delete from boards where serno=$serno"); + + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t

\n"; + echo "\t\t
\n"; + printf("\t\t\t%s\n", $errstr); + echo "\t\t
\n"; + echo "\t
\n"; + } + else { + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe board with serial number $serno was" + . " successfully deleted\n"; + mysql_query("delete from log where serno=$serno"); + if (mysql_errno()) { + $errstr = mysql_error(); + echo "\t\t\t\n"; + echo "\t\t\t\t

\n"; + echo "\t\t\t\t\tBut the following error occurred " . + "when deleting the log entries:\n"; + echo "\t\t\t\t

\n"; + echo "\t\t\t\t
\n"; + printf("\t\t\t\t\t%s\n", $errstr); + echo "\t\t\t\t
\n"; + echo "\t\t\t
\n"; + } + echo "\t\t

\n"; + echo "\t
\n"; + } +?> +

+ + + + + +
+ Back to Browse + + Back to Start +
+ diff --git a/tools/bddb/dodellog.php b/tools/bddb/dodellog.php new file mode 100644 index 000000000..d5822c5fd --- /dev/null +++ b/tools/bddb/dodellog.php @@ -0,0 +1,55 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // dodelete page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Delete Log Entry Results"); + + if (!($serno=intval($serno))) + die("the board serial number was not specified"); + + if (!isset($logno) || $logno == 0) + die("the log entry number not specified!"); + + mysql_query("delete from log where serno=$serno and logno=$logno"); + + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t

\n"; + echo "\t\t
\n"; + printf("\t\t\t%s\n", $errstr); + echo "\t\t
\n"; + echo "\t
\n"; + } + else { + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe log entry with log number $logno\n"; + echo "\t\t\tand serial number $serno "; + echo "was successfully deleted\n"; + echo "\t\t

\n"; + echo "\t
\n"; + } +?> +

+ + + + + +
+ ">Back to Log + + Back to Start +
+ diff --git a/tools/bddb/doedit.php b/tools/bddb/doedit.php new file mode 100644 index 000000000..110ecf39f --- /dev/null +++ b/tools/bddb/doedit.php @@ -0,0 +1,170 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Board Results"); + + if ($serno == 0) + die("the board serial number was not specified"); + + $query="update boards set"; + + if (isset($ethaddr)) { + if (!eth_addr_is_valid($ethaddr)) + die("ethaddr is invalid ('$ethaddr')"); + $query.=" ethaddr='$ethaddr',"; + } + + if (isset($date)) { + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', " . + "yyyy-mm-dd '$y-$m-$d')"); + $query.=" date='$date'"; + } + + if (isset($batch)) { + if (strlen($batch) > 32) + die("batch field too long (>32)"); + $query.=", batch='$batch'"; + } + + if (isset($type)) { + if (!in_array($type, $type_vals)) + die("Invalid type ($type) specified"); + $query.=", type='$type'"; + } + + if (isset($rev)) { + if (($rev = intval($rev)) <= 0 || $rev > 255) + die("Revision number is invalid ($rev)"); + $query.=sprintf(", rev=%d", $rev); + } + + if (isset($location)) { + if (strlen($location) > 64) + die("location field too long (>64)"); + $query.=", location='$location'"; + } + + if (isset($comments)) + $query.=", comments='" . rawurlencode($comments) . "'"; + + $query.=gather_enum_multi_query("sdram", 4); + + $query.=gather_enum_multi_query("flash", 4); + + $query.=gather_enum_multi_query("zbt", 16); + + $query.=gather_enum_multi_query("xlxtyp", 4); + $nxlx = count_enum_multi("xlxtyp", 4); + + $query.=gather_enum_multi_query("xlxspd", 4); + if (count_enum_multi("xlxspd", 4) != $nxlx) + die("number of xilinx speeds not same as number of types"); + + $query.=gather_enum_multi_query("xlxtmp", 4); + if (count_enum_multi("xlxtmp", 4) != $nxlx) + die("number of xilinx temps. not same as number of types"); + + $query.=gather_enum_multi_query("xlxgrd", 4); + if (count_enum_multi("xlxgrd", 4) != $nxlx) + die("number of xilinx grades not same as number of types"); + + if (isset($cputyp)) { + $query.=", cputyp='$cputyp'"; + if ($cpuspd == '') + die("must specify cpu speed if cpu type is defined"); + $query.=", cpuspd='$cpuspd'"; + if ($cpmspd == '') + die("must specify cpm speed if cpu type is defined"); + $query.=", cpmspd='$cpmspd'"; + if ($busspd == '') + die("must specify bus speed if cpu type is defined"); + $query.=", busspd='$busspd'"; + } + else { + if (isset($cpuspd)) + die("can't specify cpu speed if there is no cpu"); + if (isset($cpmspd)) + die("can't specify cpm speed if there is no cpu"); + if (isset($busspd)) + die("can't specify bus speed if there is no cpu"); + } + + if (isset($hschin)) { + if (($hschin = intval($hschin)) < 0 || $hschin > 4) + die("Invalid number of hs input chans ($hschin)"); + } + else + $hschin = 0; + if (isset($hschout)) { + if (($hschout = intval($hschout)) < 0 || $hschout > 4) + die("Invalid number of hs output chans ($hschout)"); + } + else + $hschout = 0; + if (isset($hstype)) + $query.=", hstype='$hstype'"; + else { + if ($hschin != 0) + die("number of high-speed input channels must be zero" + . " if high-speed chip is not present"); + if ($hschout != 0) + die("number of high-speed output channels must be zero" + . " if high-speed chip is not present"); + } + $query.=", hschin='$hschin'"; + $query.=", hschout='$hschout'"; + + $query.=" where serno=$serno"; + + mysql_query($query); + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t

\n"; + echo "\t\t
\n"; + printf("\t\t\t%s\n", $errstr); + echo "\t\t
\n"; + echo "\t
\n"; + } + else { + $sernos = array($serno); + $nsernos = 1; + + write_eeprom_cfg_file(); + + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe board with serial number $serno was" + . " successfully updated"; + if ($numerrs > 0) { + $errstr = $cfgerrs[0]; + echo "
\n\t\t\t"; + echo "(but the cfg file update failed: $errstr)"; + } + echo "\n"; + echo "\t\t

\n"; + echo "\t
\n"; + } + +?> +

+ + + + + +
Back to BrowseBack to Start
+ diff --git a/tools/bddb/doedlog.php b/tools/bddb/doedlog.php new file mode 100644 index 000000000..db27c37eb --- /dev/null +++ b/tools/bddb/doedlog.php @@ -0,0 +1,66 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Log Entry Results"); + + if ($serno == 0) + die("the board serial number was not specified"); + + if (!isset($logno) || $logno == 0) + die("log number not specified!"); + + $query="update log set"; + + if (isset($date)) { + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', " . + "yyyy-mm-dd '$y-$m-$d')"); + $query.=" date='$date'"; + } + + if (isset($details)) + $query.=", details='" . rawurlencode($details) . "'"; + + $query.=" where serno=$serno and logno=$logno"; + + mysql_query($query); + if(mysql_errno()) { + $errstr = mysql_error(); + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe following error was encountered:\n"; + echo "\t\t

\n"; + echo "\t\t
\n"; + printf("\t\t\t%s\n", $errstr); + echo "\t\t
\n"; + echo "\t
\n"; + } + else { + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe log entry with log number $logno and\n"; + echo "\t\t\tserial number $serno "; + echo "was successfully updated\n"; + echo "\t\t

\n"; + echo "\t
\n"; + } + +?> +

+ + + + + +
">Back to LogBack to Start
+ diff --git a/tools/bddb/donew.php b/tools/bddb/donew.php new file mode 100644 index 000000000..0f6e0d75e --- /dev/null +++ b/tools/bddb/donew.php @@ -0,0 +1,228 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Board Registration Results"); + + if (($serno=intval($serno)) != 0) + die("serial number must not be set ($serno) when Creating!"); + + $query="update boards set"; + + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')"); + $query.=" date='$date'"; + + if ($batch != '') { + if (strlen($batch) > 32) + die("batch field too long (>32)"); + $query.=", batch='$batch'"; + } + + if (!in_array($type, $type_vals)) + die("Invalid type ($type) specified"); + $query.=", type='$type'"; + + if (($rev = intval($rev)) <= 0 || $rev > 255) + die("Revision number is invalid ($rev)"); + $query.=sprintf(", rev=%d", $rev); + + $query.=gather_enum_multi_query("sdram", 4); + + $query.=gather_enum_multi_query("flash", 4); + + $query.=gather_enum_multi_query("zbt", 16); + + $query.=gather_enum_multi_query("xlxtyp", 4); + $nxlx = count_enum_multi("xlxtyp", 4); + + $query.=gather_enum_multi_query("xlxspd", 4); + if (count_enum_multi("xlxspd", 4) != $nxlx) + die("number of xilinx speeds not same as number of types"); + + $query.=gather_enum_multi_query("xlxtmp", 4); + if (count_enum_multi("xlxtmp", 4) != $nxlx) + die("number of xilinx temps. not same as number of types"); + + $query.=gather_enum_multi_query("xlxgrd", 4); + if (count_enum_multi("xlxgrd", 4) != $nxlx) + die("number of xilinx grades not same as number of types"); + + if ($cputyp == '') { + if ($cpuspd != '') + die("can't specify cpu speed if there is no cpu"); + if ($cpmspd != '') + die("can't specify cpm speed if there is no cpu"); + if ($busspd != '') + die("can't specify bus speed if there is no cpu"); + } + else { + $query.=", cputyp='$cputyp'"; + if ($cpuspd == '') + die("must specify cpu speed if cpu type is defined"); + $query.=", cpuspd='$cpuspd'"; + if ($cpmspd == '') + die("must specify cpm speed if cpu type is defined"); + $query.=", cpmspd='$cpmspd'"; + if ($busspd == '') + die("must specify bus speed if cpu type is defined"); + $query.=", busspd='$busspd'"; + } + + if (($hschin = intval($hschin)) < 0 || $hschin > 4) + die("Invalid number of hs input chans ($hschin)"); + if (($hschout = intval($hschout)) < 0 || $hschout > 4) + die("Invalid number of hs output chans ($hschout)"); + if ($hstype == '') { + if ($hschin != 0) + die("number of high-speed input channels must be zero" + . " if high-speed chip is not present"); + if ($hschout != 0) + die("number of high-speed output channels must be zero" + . " if high-speed chip is not present"); + } + else + $query.=", hstype='$hstype'"; + $query.=", hschin='$hschin'"; + $query.=", hschout='$hschout'"; + + // echo "final query = '$query'
\n"; + + $quant = intval($quant); + if ($quant <= 0) $quant = 1; + + $sernos = array(); + if ($geneths) + $ethaddrs = array(); + + $sqlerr = ''; + + while ($quant-- > 0) { + + mysql_query("insert into boards (serno) values (null)"); + if (mysql_errno()) { + $sqlerr = mysql_error(); + break; + } + + $serno = mysql_insert_id(); + if (!$serno) { + $sqlerr = "couldn't allocate new serial number"; + break; + } + + mysql_query($query . " where serno=$serno"); + if (mysql_errno()) { + $sqlerr = mysql_error(); + break; + } + + array_push($sernos, $serno); + + if ($geneths) { + + $ethaddr = gen_eth_addr($serno); + + mysql_query("update boards set ethaddr='$ethaddr'" . + " where serno=$serno"); + if (mysql_errno()) { + $sqlerr = mysql_error(); + + array_push($ethaddrs, + "" . + "db save fail" . + ""); + break; + } + + array_push($ethaddrs, $ethaddr); + } + } + + $nsernos = count($sernos); + + if ($nsernos > 0) { + + write_eeprom_cfg_file(); + + echo "\n"; + echo "\t

\n"; + echo "\t\tThe following board serial numbers were" + . " successfully allocated"; + if ($numerrs > 0) + echo " (but with $numerrs cfg file error" . + ($numerrs > 1 ? "s" : "") . ")"; + echo ":\n"; + echo "\t

\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\t\n"; + if ($numerrs > 0) + echo "\t\n"; + if ($geneths) + echo "\t\n"; + echo "\n"; + + for ($i = 0; $i < $nsernos; $i++) { + + $serno = sprintf("%010d", $sernos[$i]); + + echo "\n"; + + echo "\t\n"; + + if ($numerrs > 0) { + if (($errstr = $cfgerrs[$i]) == '') + $errstr = ' '; + echo "\t\n"; + } + + if ($geneths) { + echo "\t\n"; + } + + echo "\n"; + } + + echo "
Serial NumberCfg File ErrsEthernet Address
" . + "$serno" . + "" . + $errstr . + "" . + "" . + $ethaddrs[$i] . + "
\n"; + } + + if ($sqlerr != '') { + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe following SQL error was encountered:\n"; + echo "\t\t

\n"; + echo "\t\t
\n"; + printf("\t\t\t%s\n", $sqlerr); + echo "\t\t
\n"; + echo "\t
\n"; + } + +?> +

+ + + + + +
Go to BrowseBack to Start
+ diff --git a/tools/bddb/donewlog.php b/tools/bddb/donewlog.php new file mode 100644 index 000000000..b00de955b --- /dev/null +++ b/tools/bddb/donewlog.php @@ -0,0 +1,76 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // doedit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Add Log Entry Results"); + + if ($serno == 0) + die("serial number not specified!"); + + if (isset($logno)) + die("log number must not be set ($logno) when Creating!"); + + $query="update log set serno=$serno"; + + list($y, $m, $d) = split("-", $date); + if (!checkdate($m, $d, $y) || $y < 1999) + die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')"); + $query.=", date='$date'"; + + if (isset($details)) + $query.=", details='" . rawurlencode($details) . "'"; + + // echo "final query = '$query'
\n"; + + $sqlerr = ''; + + mysql_query("insert into log (logno) values (null)"); + if (mysql_errno()) + $sqlerr = mysql_error(); + else { + $logno = mysql_insert_id(); + if (!$logno) + $sqlerr = "couldn't allocate new serial number"; + else { + mysql_query($query . " where logno=$logno"); + if (mysql_errno()) + $sqlerr = mysql_error(); + } + } + + if ($sqlerr == '') { + echo "\n"; + echo "\t

\n"; + echo "\t\tA log entry with log number '$logno' was " . + "added to the board with serial number '$serno'\n"; + echo "\t

\n"; + echo "\n"; + } + else { + echo "\t\n"; + echo "\t\t

\n"; + echo "\t\t\tThe following SQL error was encountered:\n"; + echo "\t\t

\n"; + echo "\t\t
\n"; + printf("\t\t\t%s\n", $sqlerr); + echo "\t\t
\n"; + echo "\t
\n"; + } + +?> +

+ + + + + +
">Go to BrowseBack to Start
+ diff --git a/tools/bddb/edit.php b/tools/bddb/edit.php new file mode 100644 index 000000000..f7d483079 --- /dev/null +++ b/tools/bddb/edit.php @@ -0,0 +1,131 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Board Registration"); + + if ($serno == 0) + die("serial number not specified!"); + + $pserno = sprintf("%010d", $serno); + + echo "
"; + echo "Board Serial Number: $pserno"; + echo "
\n"; + +?> +

+

+\n"; + + $r=mysql_query("select * from boards where serno=$serno"); + $row=mysql_fetch_array($r); + if(!$row) die("no record of serial number '$serno' in database"); + + begin_table(5); + + // ethaddr char(17) + print_field("ethaddr", $row, 17); + + // date date + print_field("date", $row); + + // batch char(32) + print_field("batch", $row, 32); + + // type enum('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY') + print_enum("type", $row, $type_vals); + + // rev tinyint(3) unsigned zerofill + print_field("rev", $row, 3, 'rev_filter'); + + // location char(64) + print_field("location", $row, 64); + + // comments text + print_field_multiline("comments", $row, 60, 10, 'text_filter'); + + // sdram[0-3] enum('32M','64M','128M','256M') + print_enum_multi("sdram", $row, $sdram_vals, 4, array()); + + // flash[0-3] enum('4M','8M','16M','32M','64M') + print_enum_multi("flash", $row, $flash_vals, 4, array()); + + // zbt[0-f] enum('512K','1M','2M','4M') + print_enum_multi("zbt", $row, $zbt_vals, 16, array()); + + // xlxtyp[0-3] enum('XCV300E','XCV400E','XCV600E') + print_enum_multi("xlxtyp", $row, $xlxtyp_vals, 4, array(), 1); + + // xlxspd[0-3] enum('6','7','8') + print_enum_multi("xlxspd", $row, $xlxspd_vals, 4, array(), 1); + + // xlxtmp[0-3] enum('COM','IND') + print_enum_multi("xlxtmp", $row, $xlxtmp_vals, 4, array(), 1); + + // xlxgrd[0-3] enum('NORMAL','ENGSAMP') + print_enum_multi("xlxgrd", $row, $xlxgrd_vals, 4, array(), 1); + + // cputyp enum('MPC8260') + print_enum("cputyp", $row, $cputyp_vals); + + // cpuspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpuspd", $row, $clk_vals); + + // cpmspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpmspd", $row, $clk_vals); + + // busspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("busspd", $row, $clk_vals); + + // hstype enum('AMCC-S2064A') + print_enum("hstype", $row, $hstype_vals); + + // hschin enum('0','1','2','3','4') + print_enum("hschin", $row, $hschin_vals); + + // hschout enum('0','1','2','3','4') + print_enum("hschout", $row, $hschout_vals); + + end_table(); + + echo "

\n"; + echo "

"; + echo "WARNING: NO UNDO ON DELETE!"; + echo "

\n"; + echo "[ delete ]"; + echo "
\n"; + echo "

\n"; +?> +

+ + + + + + + + +
+ + +   + + + +   + + Back to Start +
+

+
+ diff --git a/tools/bddb/edlog.php b/tools/bddb/edlog.php new file mode 100644 index 000000000..f819b46a0 --- /dev/null +++ b/tools/bddb/edlog.php @@ -0,0 +1,81 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - Edit Board Log Entry"); + + if ($serno == 0) + die("serial number not specified!"); + + if (!isset($logno) || $logno == 0) + die("log number not specified!"); + + $pserno = sprintf("%010d", $serno); + $plogno = sprintf("%010d", $logno); + + echo "
"; + echo "Board Serial Number: $pserno, Log Number: $plogno"; + echo "
\n"; + +?> +

+

+\n"; + echo "\n"; + + $r=mysql_query("select * from log where serno=$serno and logno=$logno"); + $row=mysql_fetch_array($r); + if(!$row) + die("no record of log entry with serial number '$serno' " . + "and log number '$logno' in database"); + + begin_table(3); + + // date date + print_field("date", $row); + + // details text + print_field_multiline("details", $row, 60, 10, 'text_filter'); + + end_table(); + + echo "

\n"; + echo "

"; + echo "WARNING: NO UNDO ON DELETE!"; + echo "

\n"; + echo "[ delete ]"; + echo "
\n"; + echo "

\n"; +?> +

+ + + + + + + + +
+ + +   + + + +   + + Back to Start +
+

+
+ diff --git a/tools/bddb/execute.php b/tools/bddb/execute.php new file mode 100644 index 000000000..7adcfec20 --- /dev/null +++ b/tools/bddb/execute.php @@ -0,0 +1,37 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + if (!isset($serno)) + $serno = 0; + else + $serno = intval($serno); + + if (!isset($submit)) + $submit = "[NOT SET]"; + + switch ($submit) { + + case "New": + require("new.php"); + break; + + case "Edit": + require("edit.php"); + break; + + case "Browse": + require("browse.php"); + break; + + case "Log": + require("brlog.php"); + break; + + default: + require("badsubmit.php"); + break; + } +?> diff --git a/tools/bddb/index.php b/tools/bddb/index.php new file mode 100644 index 000000000..9d6c7f599 --- /dev/null +++ b/tools/bddb/index.php @@ -0,0 +1,38 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + require("defs.php"); + pg_head("$bddb_label"); +?> + +
+ + + + + + + + + + +
+ + + + + + + +
+ Serial Number: + +
+
+
+ diff --git a/tools/bddb/new.php b/tools/bddb/new.php new file mode 100644 index 000000000..889c6ae6a --- /dev/null +++ b/tools/bddb/new.php @@ -0,0 +1,121 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - New Board Registration"); +?> +
+

+\n"; + + begin_table(5); + + // date date + print_field("date", array('date' => date("Y-m-d"))); + + // batch char(32) + print_field("batch", $row, 32); + + // type enum('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY') + print_enum("type", $row, $type_vals, 0); + + // rev tinyint(3) unsigned zerofill + print_field("rev", $row, 3, 'rev_filter'); + + // sdram[0-3] enum('32M','64M','128M','256M') + print_enum_multi("sdram", $row, $sdram_vals, 4, array(2)); + + // flash[0-3] enum('4M','8M','16M','32M','64M') + print_enum_multi("flash", $row, $flash_vals, 4, array(2)); + + // zbt[0-f] enum('512K','1M','2M','4M') + print_enum_multi("zbt", $row, $zbt_vals, 16, array(2, 2)); + + // xlxtyp[0-3] enum('XCV300E','XCV400E','XCV600E') + print_enum_multi("xlxtyp", $row, $xlxtyp_vals, 4, array(1), 1); + + // xlxspd[0-3] enum('6','7','8') + print_enum_multi("xlxspd", $row, $xlxspd_vals, 4, array(1), 1); + + // xlxtmp[0-3] enum('COM','IND') + print_enum_multi("xlxtmp", $row, $xlxtmp_vals, 4, array(1), 1); + + // xlxgrd[0-3] enum('NORMAL','ENGSAMP') + print_enum_multi("xlxgrd", $row, $xlxgrd_vals, 4, array(1), 1); + + // cputyp enum('MPC8260') + print_enum("cputyp", $row, $cputyp_vals, 1); + + // cpuspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpuspd", $row, $clk_vals, 4); + + // cpmspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("cpmspd", $row, $clk_vals, 4); + + // busspd enum('33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ') + print_enum("busspd", $row, $clk_vals, 2); + + // hstype enum('AMCC-S2064A') + print_enum("hstype", $row, $hstype_vals, 1); + + // hschin enum('0','1','2','3','4') + print_enum("hschin", $row, $hschin_vals, 4); + + // hschout enum('0','1','2','3','4') + print_enum("hschout", $row, $hschout_vals, 4); + + end_table(); +?> +

+ + + + + + + + + + + + + + + +
+ Allocate + + board serial number(s) +
+ + Generate Ethernet Address(es) +
+   +
+ + +   + + +
+
+ diff --git a/tools/bddb/newlog.php b/tools/bddb/newlog.php new file mode 100644 index 000000000..5ec42ac28 --- /dev/null +++ b/tools/bddb/newlog.php @@ -0,0 +1,48 @@ + ?> + + // CSIRO Manufacturing Science and Technology, Preston Lab + + // edit page (hymod_bddb / boards) + + require("defs.php"); + + pg_head("$bddb_label - New Log Entry"); + + if ($serno == 0) + die("serial number not specified!"); + + if (isset($logno)) + die("log number must not be specified when adding!"); +?> +
+

+\n"; + + begin_table(3); + + // date date + print_field("date", array('date' => date("Y-m-d"))); + + // details text + print_field_multiline("details", array(), 60, 10, 'text_filter'); + + end_table(); +?> +

+ + + + + +
+ + + +
+
+ -- cgit v1.2.3