summaryrefslogtreecommitdiff
path: root/Origin/tools/scilab/linux/macros/ARDUINO_WRITE_sim.sci
blob: e52e4450a27af6f570987e263cf40750d4cce604 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2012-2012 - Scilab ENterprises - Bruno JOFRET
//
// 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
//
//

function block=ARDUINO_WRITE_sim(block,flag)
    global port_com;
function DEBUG(message)
    disp("[DEBUG time = "+string(scicos_time())+"] {"+block.label+"} ARDUINO_WRITE Simulation: "+message);
endfunction
    select flag
     case -5 // Error

     case 0 // Derivative State Update


     case 1 // Output Update
      u1 = block.inptr(1);
      pin="2"+ascii(97+block.rpar);
      if (u1<0.1) then
          pin="2"+ascii(97+block.rpar)+"0";
//          writeserial(port_com,pin);
          write_serial(1,pin,3);
      else
          pin="2"+ascii(97+block.rpar)+"1";
//          writeserial(port_com,pin);
          write_serial(1,pin,3);
      end


     case 2 // State Update

     case 3 // OutputEventTiming

     case 4 // Initialization

     case 5 // Ending
      // FIXME: quoi faire a la fin de la simulation

//     closeserial(port_com);

     case 6 // Re-Initialisation

     case 9 // ZeroCrossing

    else // Unknown flag

    end
endfunction