Changeset 657 for trunk/user/display


Ignore:
Timestamp:
Mar 18, 2020, 11:16:59 PM (5 years ago)
Author:
alain
Message:

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user/display/display.c

    r656 r657  
    1515#include <almosmkh.h>
    1616
    17 #define FILENAME    "misc/images_128.raw"
     17#define PATH_MAX_LENGHT    128
     18
    1819#define FBF_TYPE    420         
    1920#define NPIXELS     128
     
    5657    }
    5758}       
     59
    5860////////////////
    5961int main( void )
     
    6466    unsigned int    fbf_type;
    6567    unsigned int    nbytes;
    66     unsigned int    image = 0;
    6768    int             val;
    6869    int             error;
    69 
    70     unsigned long long start_cycle;
    71 
    72     // get  start cycle
    73     get_cycle( &start_cycle );
    74 
    75     printf("\n[display] starts at cycle %d\n", (unsigned int)start_cycle );
     70    char            pathname[PATH_MAX_LENGHT];
    7671
    7772    // check frame buffer size
     
    9287    }
    9388
     89    // get pathname for input file
     90    while( 1 )
     91    {
     92        printf("\n[display] path = ");
     93
     94        error = get_string( pathname , PATH_MAX_LENGHT );
     95
     96        if ( error )  printf("\n[display error] cannot get path for input file\n" );
     97        else  break;
     98    }
     99
    94100    // open file
     101    int fd = open( pathname , O_RDONLY , 0 );
    95102
    96     FILE * f = fopen( FILENAME , NULL );
    97 //  int fd = open( FILENAME, O_RDONLY , 0 );
    98 
    99     if( f == NULL )
     103    if( fd < 0 )
    100104    {
    101         printf("\n[display error] Cannot open file <%s>\n", FILENAME );
     105        printf("\n[display error] Cannot open file <%s>\n", pathname );
    102106        exit( 0 );
    103107    }
    104108
    105     printf("\n[display] open file <%s>\n", FILENAME );
     109    printf("\n[display] open file <%s>\n", pathname );
    106110
    107     // loop on images
    108     while ( 1 )
     111    // load buffer from file
     112    nbytes = read( fd , buffer , NPIXELS * NLINES );
     113
     114    if( nbytes != NPIXELS * NLINES )
    109115    {
    110         // load image from file
    111         nbytes = fread( buffer , 1 , NPIXELS * NLINES , f );
    112 //      nbytes = read( fd , buffer , NPIXELS * NLINES );
    113         if( nbytes != NPIXELS * NLINES )
    114         {
    115             printf("\n[display error] Cannot load image %d\n", image );
    116             exit( 0 );
    117         }
    118 
    119         printf("\n[display] load image %d in buffer %x\n", image, buffer );
    120  
    121         // display image
    122         error = fbf_write( buffer , NPIXELS * NLINES , 0 );
    123 
    124         if( error )
    125         {
    126             printf("\n[display error] Cannot access frame buffer\n");
    127             exit( 0 );
    128         }
    129 
    130         printf("\n[display] display image %d\n", image );
    131 
    132         image++;
    133 
    134         // interactive behaviour
    135         val = getchar();
     116        printf("\n[display error] Cannot load image \n" );
     117        exit( 0 );
    136118    }
    137119
     120    printf("\n[display] load image in buffer %x\n", buffer );
     121 
     122    // display image
     123    error = fbf_write( buffer , NPIXELS * NLINES , 0 );
     124
     125    if( error )
     126    {
     127        printf("\n[display error] Cannot access frame buffer\n");
     128        exit( 0 );
     129    }
     130
     131    printf("\n[display] display image\n");
     132
    138133    // close file
    139    fclose( f );
    140 // close( fd );
     134    close( fd );
    141135   
    142136    exit(0);
Note: See TracChangeset for help on using the changeset viewer.