summaryrefslogtreecommitdiff
path: root/Modelica-Arduino-MDD_Arduino_Revised/Resources/src/cmd_encoder_init.c
blob: 89a53dd36fb6aca171adb86d5fc0bbedb35011b1 (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
#include <errno.h> 
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "../Include/encoder.h"
#include "../Include/serial.h"

void cmd_encoder_init(int h,int enc_mode,int pin_no_1,int pin_no_2)
{   
    
    int wr;
    char code_sent[10]="Ea";
    char c[2];

    sprintf(c,"%c",48+corresp[block->rpar[2]]);
    strcat(code_sent,c);
    if(block.rpar(2)==4)
    { 
    	char c1[2],c2[2],v[10];
    	sprintf(c1,"%c",48+0+corresp[block->rpar[3]]);
    	sprintf(v,"%s",(block->rpar[1]));
        strcat(code_sent,c1);
        strcat(code_sent,v);
    }
    else
    {
       	char c2[2],v[10];
    	sprintf(c2,"%c",48+0+corresp[block->rpar[3]]);
    	sprintf(v,"%s",block->rpar[1]);
    	strcat(code_sent,c1);
        strcat(code_sent,v);
    }
    wr=write_serial(1,code_sent,5);
    strcpy(code_sent,"Ez");
    sprintf(c,"%c",corresp[block->rpar[2]])
    strcat(code_sent,c);
    wr=write_serial(1,code_sent,3)
}