/alps/ipecamera

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/ipecamera

« back to all changes in this revision

Viewing changes to reader.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-05-01 17:21:14 UTC
  • Revision ID: csa@suren.me-20150501172114-zhfeilae8k10kvnx
Use pcitool debugging API

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t bufsize, void *buf) {
83
83
    int res;
84
84
    int eof = 0;
 
85
    
 
86
    static unsigned long packet_id = 0;
85
87
 
86
88
#ifdef IPECAMERA_BUG_MULTIFRAME_PACKETS
87
89
    size_t real_size;
94
96
    static  pcilib_event_id_t invalid_frame_id = (pcilib_event_id_t)-1;
95
97
#endif
96
98
 
97
 
#ifdef IPECAMERA_DEBUG_RAW_PACKETS
98
 
    char fname[128];
99
 
    { 
100
 
        static unsigned long packet_id = 0;
101
 
        sprintf(fname,"%s/frame%4lu", IPECAMERA_DEBUG_RAW_PACKETS, ctx->event_id);
102
 
        mkdir(fname, 0755);
103
 
        sprintf(fname,"%s/frame%4lu/frame%9lu", IPECAMERA_DEBUG_RAW_PACKETS, ctx->event_id, packet_id);
104
 
        FILE *f = fopen(fname, "w");
105
 
        if (f) {
106
 
            fwrite(buf, 1, bufsize, f);
107
 
            fclose(f);
108
 
        }
109
 
        sprintf(fname,"%s/frame%4lu/frame%9lu.invalid", IPECAMERA_DEBUG_RAW_PACKETS, ctx->event_id, packet_id++);
110
 
    }
111
 
#endif /* IPECAMERA_DEBUG_RAW_PACKETS */
112
 
    
 
99
    packet_id++;
 
100
    ipecamera_debug_buffer(RAW_PACKETS, bufsize, buf, PCILIB_DEBUG_BUFFER_MKDIR, "frame%4lu/frame%9lu", ctx->event_id, packet_id);
 
101
 
113
102
    if (!ctx->cur_size) {
114
103
#if defined(IPECAMERA_BUG_INCOMPLETE_PACKETS)||defined(IPECAMERA_BUG_MULTIFRAME_PACKETS)
115
104
        size_t startpos;
118
107
        }
119
108
        
120
109
        if ((startpos + sizeof(frame_magic)) > bufsize) {
121
 
#ifdef IPECAMERA_DEBUG_RAW_PACKETS
122
 
            FILE *f = fopen(fname, "w");
123
 
            if (f) fclose(f);
124
 
#endif /* IPECAMERA_DEBUG_RAW_PACKETS */
 
110
            ipecamera_debug_buffer(RAW_PACKETS, bufsize, NULL, 0, "frame%4lu/frame%9lu.invalid", ctx->event_id, packet_id);
125
111
            
126
112
            if (invalid_frame_id != ctx->event_id) {
127
113
//              pcilib_warning("No frame magic in DMA packet of %u bytes, current event %lu", bufsize, ctx->event_id);
179
165
 
180
166
            // just rip of padding
181
167
        bufsize = ctx->roi_raw_size - ctx->cur_size;
182
 
 
183
 
#ifdef IPECAMERA_DEBUG_RAW_PACKETS
184
 
        sprintf(fname + strlen(fname) - 8, ".partial");
185
 
        FILE *f = fopen(fname, "w");
186
 
        if (f) {
187
 
            fwrite(buf, 1, bufsize, f);
188
 
            fclose(f);
189
 
        }
190
 
#endif /* IPECAMERA_DEBUG_RAW_PACKETS */
 
168
        ipecamera_debug_buffer(RAW_PACKETS, bufsize, buf, 0, "frame%4lu/frame%9lu.partial", ctx->event_id, packet_id);
191
169
    }
192
170
#endif /* IPECAMERA_BUG_MULTIFRAME_PACKETS */
193
171