Revision: 1707
Author: jsuijs
Date: Thu Feb 25 11:40:34 2010
Log: extension of testfile

http://code.google.com/p/jallib/source/detail?r=1707

Modified:
 /trunk/test/jal/test_startersguide_serial.jal

=======================================
--- /trunk/test/jal/test_startersguide_serial.jal       Wed Feb 24 08:07:00 2010
+++ /trunk/test/jal/test_startersguide_serial.jal       Thu Feb 25 11:40:34 2010
@@ -1,5 +1,5 @@
 -- ------------------------------------------------------
--- Title: Test program 1 for startersguide (serial interface)
+-- Title: Test (Demo) program for startersguide (serial interface)
 --
 -- Author: Joep Suijs, Copyright (c) 2008..2010, all rights reserved.
 --
@@ -10,7 +10,8 @@
 -- This file is part of jallib  (http://jallib.googlecode.com)
-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
 --
--- Description: Test program
+-- Description: Demo program, for use in the startersguide. Much of the code is not +-- meaningful on itself, but very usefull as part of the startersguide.
 --
 -- Sources:
 --
@@ -37,129 +38,155 @@
 include print

 led_direction = output
-
-forever loop
-   delay_100ms( 5 )
-   LED = high
-   delay_100ms( 5 )
-   LED = low
-
-   -- serial_hw_data is a pseudo-var of the desired output-device.
-   serial_hw_data = "A" -- output an A to the serial port.
-
-   --
- -- The print_* and format_* routines assing the output chars to this pseudo-var.
-   --
-
-   -- output the string, the pseudo var is the first param.
-   const byte str1[] = " - Test print.jal- bytes\r\n"   -- define a string
-   print_string(serial_hw_data, str1)                 -- output string
--- print_string(serial_hw_data, " - Test print.jal- bytes\r\n") -- output string (not yet supported by JAL)
-
-   -- -----------
-   -- byte stuff
-   -- -----------
-   var  byte a =  210
-   var sbyte b = -109
-
- print_byte_dec(serial_hw_data, a) -- output in (unsigned) decimal format - print_crlf(serial_hw_data) -- output Carriage Return and Linefeed (0x0D 0x0A), new line
-   print_byte_hex(serial_hw_data, a)   -- output in hex format
-   print_crlf(serial_hw_data)
-   print_byte_binary(serial_hw_data, a)   -- output in binary format
-   print_crlf(serial_hw_data)
-
-   print_sbyte_dec(serial_hw_data, b)   -- output in signed decimal format
-   print_crlf(serial_hw_data)
-
-
-   -- -----------
-   -- word stuff
-   -- -----------
-   const byte str2[] = "Test print.jal - words\r\n"   -- define a string
-   print_string(serial_hw_data, str2)
-
-   var  word c =  45678
-   var sword d = -32109
-
- print_word_dec(serial_hw_data, c) -- output in (unsigned) decimal format - print_crlf(serial_hw_data) -- output Carriage Return and Linefeed (0x0D 0x0A), new line
-   print_word_hex(serial_hw_data, c)   -- output in hex format
-   print_crlf(serial_hw_data)
-   print_word_binary(serial_hw_data, c)   -- output in binary format
-   print_crlf(serial_hw_data)
-
-   print_sword_dec(serial_hw_data, d)   -- output in signed decimal format
-   print_crlf(serial_hw_data)
-
-   -- -----------
-   -- dword stuff
-   -- -----------
-   const byte str3[] = "Test print.jal - dwords\r\n"   -- define a string
-   print_string(serial_hw_data, str3)
-
-   var  dword e =  3210987654
-   var sdword f = -2109876543
-
- print_dword_dec(serial_hw_data, e) -- output in (unsigned) decimal format - print_crlf(serial_hw_data) -- output Carriage Return and Linefeed (0x0D 0x0A), new line
-   print_dword_hex(serial_hw_data, e)   -- output in hex format
-   print_crlf(serial_hw_data)
-   print_dword_binary(serial_hw_data, e)   -- output in binary format
-   print_crlf(serial_hw_data)
-
-   print_sdword_dec(serial_hw_data, f)   -- output in signed decimal format
-   print_crlf(serial_hw_data)
-
-   -- -----------
-   -- bit stuff
-   -- -----------
-   const byte str4[] = "Test print.jal - bit\r\n"   -- define a string
-   print_string(serial_hw_data, str4)
-
-   var bit g = 1
-
-   print_bit_10(serial_hw_data, g)           -- output 0 or 1
-   serial_hw_data = " "                      -- output a space
-
-   print_bit_highlow(serial_hw_data, g)      -- output text 'high' or 'low'
-   serial_hw_data = " "                      -- output a space
-
- print_bit_truefalse(serial_hw_data, g) -- output text 'true' or 'false'
-   serial_hw_data = " "                      -- output a space
-
-   g = 0
-
-   print_bit_10(serial_hw_data, g)           -- output 0 or 1
-   serial_hw_data = " "                      -- output a space
-
-   print_bit_highlow(serial_hw_data, g)      -- output text 'high' or 'low'
-   serial_hw_data = " "                      -- output a space
-
- print_bit_truefalse(serial_hw_data, g) -- output text 'true' or 'false'
-
-   print_crlf(serial_hw_data)
-
-
-   -- -------------
-   -- and together:
-   -- -------------
-
-   var byte x = "y"
-   const byte str5[] = "Variable x has decimal value "
-   print_string(serial_hw_data, str5)
-   print_byte_dec(serial_hw_data, x)
-
-   const byte str6[] = " which is hex value "
-   print_string(serial_hw_data, str6)
-   print_byte_hex(serial_hw_data, x)
-
-   const byte str7[] = " and represents ASCII character "
-   print_string(serial_hw_data, str7)
-   serial_hw_data = x
-
-   print_crlf(serial_hw_data)
-   print_crlf(serial_hw_data)
-
+
+
+-- pseudo variable part
+var byte PvStore
+
+procedure pv'put(byte in invar) is
+   PvStore = invar + 1
+end procedure
+
+function pv'get() return byte is
+   return PvStore * 2
+end function
+
+-- definition of (dummy) procedure and fuctions
+procedure sgd_initialize() is
+   ;
+end procedure
+
+function sgd_transmit_byte(byte in data) return bit is
+       ;
+   data = 123
+end function
+
+function sgd_receive_function() return byte is
+   var byte data = 0
+       ;
+   return data
+end function
+
+procedure sgd_receive_procedure(bit in ACK, byte in out data) is
+   data = 0
+       ;
+end procedure
+
+
+var  byte   alpha  = 0b0100_0011 -- binary
+;var  byte*4 bravo  = 0q203       -- octal
+var dword   charly = 0x43        -- hex
+var  byte*3 delta
+var  byte   echo[3] at delta
+var  byte   foxtrot[10]
+var  byte   hotel[]   = { 1, 2, 4 }
+var  byte   india[]    = "foxtrot"
+var  bit    julia at alpha:0
+
+const byte str1[] = "Hello startersguide world!"
+
+var byte x
+
+forever loop
+   delay_100ms(5)
+   print_string(serial_hw_data, str1)
+
+   if (Alpha > 0) then
+      Alpha = Alpha + 1
+   end if
+
+   If (Alpha > 0) THEN
+      alpha = AlPhA + 1
+   END IF
+
+   alpha = charly
+
+   alpha = byte(charly)
+   x = sgd_receive_function()
+
+   pv = 7
+   print_byte_dec(serial_hw_data, pv)
+   print_crlf(serial_hw_data)
+
+   if (x > 0) then
+      x = x - 1
+   end if
+
+   if (x > 0) then
+      x = x - 1
+   else
+      x = x + 1
+   end if
+
+   if (x == 1) then
+      x = x + 1
+   elsif (x > 7) then
+      x = x + 2
+   else
+      x = x + 3
+   end if
+   print_byte_dec(serial_hw_data, x)
+   print_crlf(serial_hw_data)
+
+   case (x) of
+      1 : block
+         x = 1
+      end block
+      2 : block
+         x = 3
+      end block
+      3 : block
+         x = 2
+      end block
+      otherwise block
+         x = x / 2
+      end block
+   end case
+   print_byte_dec(serial_hw_data, x)
+   print_crlf(serial_hw_data)
+
+   x = 0
+   forever loop
+      serial_hw_data = "!"
+      x = x + 1
+      if (x > 10) then
+         exit loop
+      end if
+   end loop
+   print_crlf(serial_hw_data)
+
+   for 7 loop
+      serial_hw_data = "@"
+   end loop
+   print_crlf(serial_hw_data)
+
+   var byte lc
+   for 7 using lc loop
+      print_byte_dec(serial_hw_data, lc)
+      serial_hw_data = " "
+   end loop
+   print_crlf(serial_hw_data)
+
+   var byte x = 0
+   repeat
+      serial_hw_data = "#"
+      x = x + 1
+   until (x == 0)
+   print_crlf(serial_hw_data)
+
+   x = 0
+   while (x > 0) loop
+      serial_hw_data = "$"
+      x = x - 1
+   end loop
+   print_crlf(serial_hw_data)
+
+   x = 4
+   while (x > 0) loop
+      serial_hw_data = "%"
+      x = x - 1
+   end loop
+   print_crlf(serial_hw_data)
+
 end loop

--
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to