Stack Exchange
how to decode raw IR data using lirc on raspberry pi 3
I've been trying to decode my IR raw data but always getting unknown code. i used 
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#define SHORT 600
#define LONG 300
#define MARGIN 200
#define INTRO 3500
#define INTRO2 1700
#define SEPARATOR 9880


char decode(int val1, int val2){
if (abs(val1 - INTRO) < MARGIN && abs(val2 - 
INTRO2) < MARGIN)
return '[';
if (abs(val1 - SHORT) < MARGIN && abs(val2 - 
SHORT) < MARGIN)
    return '0';
if (abs(val1 - SHORT) < MARGIN && abs(val2 - 
LONG) < MARGIN)
    return '1';
if (abs(val1 - SHORT) < MARGIN && abs(val2 - 
SEPARATOR) < MARGIN)
    return ']'; 
}

int abs(int val){
if (val < 0)
    return -val;
else
    return val;
}

int main(int argc, char** argv){
if (argc < 3){
    printf("usage = %s fileName output\n", 
argv[0]);
    exit(0);
}
int val1, val2;
char delims[] = " ";
char *result = NULL;
FILE* f = fopen(argv[1],"r");
FILE* out = fopen(argv[2],"w");
char line[256];
int index = 0;
char* nIndex = 0;
while (fgets(line, 256, f) != NULL){
    result = strtok( line, delims );
    index = 0;
    while( result != NULL ) {
        //printf( "result[%d] is \"%s\"\n", 
 index, result );
        if (index & 1){
            if (nIndex = strchr(result,'\n')){
                //printf("New line detected in result\n");
                *nIndex = '\0';
            }
            val2 = atoi(result);
            char dec = decode(val1,val2);
            fprintf(out,"%c",dec);
        }else{
            val1 = atoi(result);
        }
        result = strtok( NULL, delims );
        index++;
    }
    //printf (line);
}
fprintf(out, "]\n");
fclose(f);
fclose(out);
}

and my Raw data are
3596     1598      574      298      574     1166
  572      301      603      268      576      295
  573      298      600      271      610      260
  577      295      572      299      573      298
  573      299      603      268      577     1164
  574      298      574      296      573      299
  543      329      575      295      571      301
  573      298      569     1173      576     1165
  546     1197      662      184      636      261
  544     1198      600      271      573      299
  573      297      574      297      544      328
  605      266      573      299      544      326
  573      298      605      266      575      296
  576      296      543      327      575      296
  604      268      575      297      515      356
  599      272      572      298      601      271
  571      299      574      301      573      295
  576      295      573      279      561      329
  545      325      546      325      573      300
  573      297      573     1169      572     1170
  574      298      544      327      575      296
  547      325      511      359      603    76167

 3599     1625      548      322      553     1189
  552      321      523      348      550      321
  551      320      517      354      574      297
  551      320      551      321      577      293
  547      325      550      321      521     1219
  525      348      552      319      550      321
  549      322      552      320      549      322
  550      321      548     1193      551     1191
  584     1159      518      353      549      322
  580     1170      546      317      551      321
  552      319      579      292      551      320
  552      320      551      320      553      318
  549      322      579      292      547      324
  550      321      555      317      550      320
  581     1160      587      286      543     1198
  552     1190      552     1191      550      321
  551      321      581      290      547      324
  549      322      550      321      548     1193
  552     1191      550      319      583      292
  550      320      576      295      579      292
  551      320      519      353      551      319
  548      323      553     1189      522     1220
  550     1192      550     1192      551     1192
  523     1219      551     1191      451     1291
  522      350      550      321      553      318
  548      323      555      316      551      320
  553      319      552      319      554      316
  584      300      566      294      550      320
  552      319      549      322      550      321
  553      321      552      317      549      321
  550     1192      523     1219      550     1192
  558      314      549      322      552      319
  551      321      552      318      552      320
  551      320      549      322      551      320
  550     1192      548     1194      550     1192
  551      320      613      258      526      346
  554      319      549      322      522      348
  576      294      522      350      522      348
  555      317      523      348      552      319
  552      319      550      321      548      323
  552      319      580     1161      551      322
  553      318      551      320      549      322
  608      263      582      289      525     1216
  550      322      521      350      552      320
  551      320      552      319      549      322
  581      290      551      321      550      320
  552      319      555      317      523      348
  548      324      551      319      546      325
  551      321      479      391      572     1169
  551     1192      554     1188      555     1188
  551      321      549     1191      557     1187
  551

and i got 

[1�11111111111�1111111��#11#111111111111111111111111111111��11111�[1
  11111111111+1111111##�11�11111111111111�1###111111##111111111
  ,###+#s111111111111111111#+#111111111###1111111111111111�111111(11111111111111111�#

please help me, thank you!

I'm looking for a solution for same problem. Did you solve that problem?

It looks like you may be reading a remote intended for a Mitsubishi air conditioning system. Unlike most remotes, which just send a short signal corresponding to the button pressed and rely on the device being controlled to remember its previous state, Mitsubishi decided to transmit the entire desired state of the machine -- all the mode, fan, vane, and other settings get sent Every Time, as an 18-byte data block with checksum (which the remote then repeats once, as insurance against optical noise).
If you websearch "Mitsubishi minisplit IR protocol", you'll find some pages where people have at least partially analyzed this protocol.
This isn't the kind of approach LIRC's higher-level tools were designed to handle. You can still use the LIRC drivers, but they have to be accessed in "raw" mode and separate tools are used to interpret incoming signal or generate outgoing signal.
Searching Github finds libraries/tools others have written to work with this protocol. I haven't found one in a language I actually like working with, though, so I'm assuming I'm going to have to access the LIRC api calls to read/write the data and interpret/generate it myself.
RELATED: If you're using the ir-ctl program to do basic "raw" reading and writing while you test your hardware, be aware that ir-ctl's transmit mode has a line-length limit which this protocol sometimes exceeds if you put it all on a single line of text. The workaround is to insert line breaks every so often, so no single line of the input exceeds that hardcoded limit. (Yes, I've filed a bug report.)

I am not used to playing with IR, but ...
If you want to use lirc you should configure it : http://lirc.org/html/configuration-guide.html.
You do not need to develop a specific utility to decode data.
You can use mode2 to get output form driver http://www.lirc.org/html/mode2.html
mode2 --driver default --device /dev/lirc0
 Using driver default on device /dev/lirc0
 Trying device: /dev/lirc0
 Using device: /dev/lirc0
 pulse 2750
 space 800
 pulse 500
 space 350
 pulse 550
 space 350
 pulse 550

Then lircd.conf is used to map data to key http://www.lirc.org/html/lircd.conf.html and with irw you get the result :
$ irw
    000000037ff07bef 00 KEY_VOLUMEUP Acer_Aspire_6530G_MCE
    000000037ff07bef 01 KEY_VOLUMEUP Acer_Aspire_6530G_MCE
    000000037ff07bdd 00 KEY_ENTER Acer_Aspire_6530G_MCE
    000000037ff07bdd 02 KEY_ENTER Acer_Aspire_6530G_MCE


hi, thank you for the answer, yes i'm using lirc for receiving the IR signal, the problem i'm facing now is my signal is too long and somehow can't be map. any advice?
