[DEV] Add the display by slot

This commit is contained in:
Edouard DUPIN 2013-02-12 13:08:17 +01:00
parent 0c31724556
commit a1b692e60b
5 changed files with 228 additions and 63 deletions

112
display.c
View File

@ -22,7 +22,7 @@
extern fileProperties_ts fileProp[2];
void drawLine(void)
void drawLine(bool returnLine)
{
showTypeSize_te mySize = getTypeSize();
showType_te myType = getType();
@ -33,16 +33,16 @@ void drawLine(void)
switch(mySize)
{
case SHOW_TYPE_SIZE_8:
printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
break;
case SHOW_TYPE_SIZE_16:
printf("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
break;
case SHOW_TYPE_SIZE_32:
printf("---------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("---------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
break;
case SHOW_TYPE_SIZE_64:
printf("-------------------------------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("-------------------------------------------------------------------------------------------------------------------------------------------");
break;
default:
break;
@ -53,22 +53,27 @@ void drawLine(void)
switch(mySize)
{
case SHOW_TYPE_SIZE_8:
printf("---------------------------------------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("---------------------------------------------------------------------------------------------------------------------------------------------------");
break;
case SHOW_TYPE_SIZE_16:
printf("-----------------------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("-----------------------------------------------------------------------------------------------------------------------------------");
break;
case SHOW_TYPE_SIZE_32:
printf("---------------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("---------------------------------------------------------------------------------------------------------------------------");
break;
case SHOW_TYPE_SIZE_64:
printf("-----------------------------------------------------------------------------------------------------------------------\n"COLOR_NORMAL);
printf("-----------------------------------------------------------------------------------------------------------------------");
break;
default:
break;
}
break;
}
if (returnLine==true) {
printf("\n"COLOR_NORMAL);
} else {
printf("\r"COLOR_NORMAL);
}
}
const char* getTypeChar(showType_te myType)
@ -124,14 +129,15 @@ void showConfiguration(void)
printf(GO_TOP);
printf(COLOR_BOLD_GREEN);
drawLine();
drawLine(true);
printf(COLOR_GREEN);
printf("| hexViewer | offset : %7d octets | ", (int)getOfsetFile());
printf(" Type (t) : ");
printf("%s", getTypeChar(myType));
printf("| hexViewer | offset : %7d octets ", (int)getOfsetFile());
printf(" | Type (t) : %s", getTypeChar(myType));
printf(" | ");
printf(" | Size (s) : %s", getTypeSizeChar(mySize));
printf(" | Slot (u+/i-/j/k) : %d (%s)", getSlotSize(), (getSlotDisplayMode()?"enable ":"disable"));
printf(" | Padding (o+/p-/m) : %d ", getPaddingOffsetFile());
printf(" | ");
printf(" Size (s) : ");
printf("%s", getTypeSizeChar(mySize));
printf(COLOR_NORMAL"\n");
printf(COLOR_GREEN"| File Left << | [%s%s slot=%4d delta=%4d] " COLOR_BOLD_GREEN "%s\n" COLOR_NORMAL,
@ -148,7 +154,7 @@ void showConfiguration(void)
fileProp[1].name);
printf(COLOR_BOLD_GREEN);
drawLine();
drawLine(true);
}
void printNoElement(showType_te localType, showTypeSize_te localSize)
@ -288,7 +294,7 @@ void compareFile(FILE *filePointer1, FILE *filePointer2 ,int32_t curentFilePosit
inputData_tu data1;
inputData_tu data2;
uint32_t i;
uint32_t j;
uint32_t jjj;
showConfiguration();
@ -350,8 +356,34 @@ void compareFile(FILE *filePointer1, FILE *filePointer2 ,int32_t curentFilePosit
// Display the main show
printf(COLOR_BOLD_YELLOW);
drawLine();
for (j=0; j < (uint32_t)(GetNumberOfRaw()-NB_HEARDER_RAW); j++) {
drawLine(true);
int32_t counterLineID;
int32_t offsetDisplaySlot=0;
int32_t sizeSlotByte;
switch(getTypeSize())
{
default:
case SHOW_TYPE_SIZE_8:
sizeSlotByte = 1*getSlotSize();
break;
case SHOW_TYPE_SIZE_16:
sizeSlotByte = 2*getSlotSize();
break;
case SHOW_TYPE_SIZE_FLOAT:
case SHOW_TYPE_SIZE_32:
sizeSlotByte = 4*getSlotSize();
break;
case SHOW_TYPE_SIZE_DOUBLE:
case SHOW_TYPE_SIZE_64:
sizeSlotByte = 8*getSlotSize();
break;
}
if (true == getSlotDisplayMode() && 0<getSlotSize()) {
int32_t nbElementToRead = NB_DATA_PER_LINE*4;
int32_t positionInSlot = curentFilePosition%sizeSlotByte;
offsetDisplaySlot = positionInSlot%nbElementToRead;
}
for (jjj=0, counterLineID=0; jjj < (uint32_t)(GetNumberOfRaw()-NB_HEARDER_RAW); jjj++, counterLineID++) {
uint32_t readFile1 = 0;
uint32_t readFile2 = 0;
int32_t lineNumber = 0;
@ -359,20 +391,48 @@ void compareFile(FILE *filePointer1, FILE *filePointer2 ,int32_t curentFilePosit
// read data in files :
memset(data1.data_8, 0, 16 * sizeof(uint8_t));
memset(data2.data_8, 0, 16 * sizeof(uint8_t));
// Generate the ofset in the file
int32_t positionStartDisplayFile1 = curentFilePosition + j*NB_DATA_PER_LINE*4;
int32_t positionStartDisplayFile2 = curentFilePosition + j*NB_DATA_PER_LINE*4;
int32_t positionStartDisplayFile1 = curentFilePosition + offsetDisplaySlot;
int32_t positionStartDisplayFile2 = curentFilePosition + offsetDisplaySlot;
if (currentPadding < 0) {
positionStartDisplayFile1 += currentPadding;
} else {
positionStartDisplayFile2 -= currentPadding;
}
if (true == getSlotDisplayMode() && 0<getSlotSize()) {
if (positionStartDisplayFile1%sizeSlotByte==0) {
drawLine(false);
printf(" Frame | %9d |\n", positionStartDisplayFile1/sizeSlotByte);
jjj++;
}
if (jjj >= (uint32_t)(GetNumberOfRaw()-NB_HEARDER_RAW)) {
return;
}
}
int32_t nbElementToRead = NB_DATA_PER_LINE*4;
if (true == getSlotDisplayMode() && 0<getSlotSize()) {
int32_t posituionInSlot = positionStartDisplayFile1%sizeSlotByte;
if (posituionInSlot+nbElementToRead>sizeSlotByte) {
nbElementToRead = sizeSlotByte - posituionInSlot;
}
}
/*
if (nbElementToRead != NB_DATA_PER_LINE*4) {
printf(" \r");
printf("nbElementToRead=%d\n",nbElementToRead);
jjj++;
}
*/
readFile1 = 0;
int32_t readStartFile1 = 16;
if (filePointer1 != NULL) {
if (positionStartDisplayFile1 >= 0) {
fseek(filePointer1 , positionStartDisplayFile1+fileProp[0].fileBasicOffset , SEEK_SET );
readFile1 = fread(data1.data_8, sizeof(uint8_t), 16, filePointer1);
readFile1 = fread(data1.data_8, sizeof(uint8_t), nbElementToRead, filePointer1);
readStartFile1 = 0;
} else if (positionStartDisplayFile1 > -NB_DATA_PER_LINE*4) {
fseek(filePointer1 , fileProp[0].fileBasicOffset , SEEK_SET );
@ -387,7 +447,7 @@ void compareFile(FILE *filePointer1, FILE *filePointer2 ,int32_t curentFilePosit
if (filePointer2 != NULL) {
if (positionStartDisplayFile2 >= 0) {
fseek(filePointer2 , positionStartDisplayFile2+fileProp[1].fileBasicOffset , SEEK_SET );
readFile2 = fread(data2.data_8, sizeof(uint8_t), 16, filePointer2);
readFile2 = fread(data2.data_8, sizeof(uint8_t), nbElementToRead, filePointer2);
readStartFile2 = 0;
} else if (positionStartDisplayFile2 > -NB_DATA_PER_LINE*4) {
fseek(filePointer2 , fileProp[1].fileBasicOffset , SEEK_SET );
@ -619,6 +679,8 @@ void compareFile(FILE *filePointer1, FILE *filePointer2 ,int32_t curentFilePosit
} else {
printf(COLOR_BOLD_MAGENTA" | "COLOR_BOLD_YELLOW"| "COLOR_NORMAL " |\n");
}
// update file positions :
offsetDisplaySlot += nbElementToRead;
}
}
@ -638,6 +700,10 @@ void * threadDisplay (void * p_data)
uint32_t curentFilePosition = getOfsetFile();
uint32_t curentFilePadding = getPaddingOffsetFile();
compareFile(fileProp[0].pointer,fileProp[1].pointer, curentFilePosition, curentFilePadding);
if (true==getHelpDisplay()) {
showConfiguration();
usage();
}
} else {
usleep(10000);
}

View File

@ -4,9 +4,7 @@ DUMP_DIR_EXP=.
DUMP_DIR_MATLAB=..
MATLAB_PREFIX=m__
MATLAB_SUFFIX=.raw
TANGO_PREFIX=exp
TANGO_SUFFIX=.raw
DUMP_FILES=(
'WTX_')
@ -31,8 +29,8 @@ for i in "${DUMP_FILES[@]}" ; do
VALUE="$FileID"
fi
MATLAB_DUMP="$DUMP_DIR_MATLAB/$MATLAB_PREFIX$i$VALUE*$MATLAB_SUFFIX"
TANGO_DUMP="$DUMP_DIR_EXP/$TANGO_PREFIX$i$VALUE*$TANGO_SUFFIX"
MATLAB_DUMP="$DUMP_DIR_MATLAB/$MATLAB_PREFIX$i$VALUE""_*"
TANGO_DUMP="$DUMP_DIR_EXP/$TANGO_PREFIX$i$VALUE""_*"
# TODO : afficher quend un des deux fichier existe

74
main.c
View File

@ -24,40 +24,6 @@
fileProperties_ts fileProp[2];
void usage(void)
{
printf("usage : hexViwer [option] [file_1] [file_2]\n");
printf("\t[option] : options:\n");
printf("\t\t[-d] : direct check of the error ...\n");
printf("\t[file_1] : Show the first file only\n");
printf("\t[file_2] : if it was precise : Show the comparaison with the first file\n");
printf("\t\n");
printf("\tInside Usage : \n");
printf("\t\t[a] Go to the start of the files\n");
printf("\t\t[z] Go to the end of the files (the first push is the File 1, the second push is the file 2) \n");
printf("\t\t[q] Quit the curent program\n");
printf("\t\t[s] Change the view of the propram of the size of interpretation (8/16/32/64 bits)\n");
printf("\t\t[t] Change the interpretation of Data (hexedecimal, Signed Decimal, Unigned Decimal)\n");
printf("\t\t[f] Find the first Error when comparing the two files\n");
printf("\t\t[c] Calibrate the delta between the 2 file (fist element !=0)\n");
printf("\t\t[UP] Go up (5 lines)\n");
printf("\t\t[DOWN] Go down (5 lines)\n");
printf("\t\t[LEFT] Go up (one screen)\n");
printf("\t\t[RIGHT] Go down (one screen)\n");
printf("\t\tAdd padding : \n");
printf("\t\t\t[o] Add 1 Byte padding at the left file\n");
printf("\t\t\t[O] Add 16 Bytes padding at the left file\n");
printf("\t\t\t[p] Add 1 Byte padding at the right file\n");
printf("\t\t\t[P] Add 16 Bytes padding at the right file\n");
printf("\t\t\t[m] reset padding\n");
printf("\t\n");
printf("\tCopyright: 2010 Edouard DUPIN, all right reserved\n");
printf("\tLicense: GNU Lesser General Public License (LGPL) v3.0\n");
}
int32_t findFirstDiff(void)
{
uint8_t data1, data2;
@ -245,19 +211,26 @@ void OpenFiles(void)
if (fileProp[0].typeSize == fileProp[1].typeSize) {
setTypeSize(fileProp[0].typeSize);
} else {
printf("Error The 2 files has not the same header properties header ... \n");
printf("Error The 2 files has not the same header typeSize properties header ... \n");
}
if (fileProp[0].type == fileProp[1].type) {
setType(fileProp[0].type);
} else {
printf("Error The 2 files has not the same header properties header ... \n");
printf("Error The 2 files has not the same header type properties header ... \n");
}
if (fileProp[0].slotSize == fileProp[1].slotSize) {
setSlotSize(fileProp[0].slotSize);
} else {
printf("Error The 2 files has not the same header slotSize properties header ... \n");
}
} else if (fileProp[0].fileBasicOffset!=0) {
setTypeSize(fileProp[0].typeSize);
setType(fileProp[0].type);
setSlotSize(fileProp[0].slotSize);
} else if (fileProp[1].fileBasicOffset!=0) {
setTypeSize(fileProp[1].typeSize);
setType(fileProp[1].type);
setSlotSize(fileProp[1].slotSize);
}
int32_t sizeElement=1;
showTypeSize_te tmpType = getTypeSize();
@ -515,6 +488,30 @@ int main (int argc, char**argv)
OpenFiles();
needRedraw();
break;
// Display Slot mode :
case 'j':
case 'J':
setSlotDisplayMode((getSlotDisplayMode()==true)?false:true);
needRedraw();
break;
case 'U':
setSlotSize(getSlotSize()-9);
case 'u':
setSlotSize(getSlotSize()-1);
needRedraw();
break;
case 'I':
setSlotSize(getSlotSize()+9);
case 'i':
setSlotSize(getSlotSize()+1);
needRedraw();
break;
case 'k':
case 'K':
setSlotSize(0);
setSlotDisplayMode(false);
needRedraw();
break;
// Add padding offset between left an right file
case 'o':
displayPaddingOffset(-1);
@ -537,6 +534,11 @@ int main (int argc, char**argv)
case 'C':
AutoSetPadding();
break;
case 'h':
case 'H':
setHelpDisplay((getHelpDisplay()==true)?false:true);
needRedraw();
break;
}
}
} else {

View File

@ -209,3 +209,89 @@ int32_t GetNumberOfColomn(void)
return nbColomn;
}
int32_t slotSize = -1;
bool slotEnable = false;
int32_t getSlotSize(void)
{
if (true == slotEnable) {
return slotSize;
}
return 0;
}
void setSlotSize(int32_t newSize)
{
if (newSize<0) {
newSize = 0;
}
slotSize = newSize;
}
void setSlotDisplayMode(bool enable)
{
slotEnable = enable;
}
bool getSlotDisplayMode(void)
{
return slotEnable;
}
bool displayHelp = false;
void setHelpDisplay(bool enable)
{
displayHelp = enable;
}
bool getHelpDisplay(void)
{
return displayHelp;
}
void cleanLine(void)
{
printf(" | | \r");
}
void endLine(void)
{
printf(" |-----------------------------------------------------------------------------------------------------------------------------------| \n");
}
void usage(void)
{
cleanLine(); printf(" | usage : hexViwer [option] [file_1] [file_2]\n");
cleanLine(); printf("\t[option] : options:\n");
cleanLine(); printf("\t\t[-d] : direct check of the error ...\n");
cleanLine(); printf("\t[file_1] : Show the first file only\n");
cleanLine(); printf("\t[file_2] : if it was precise : Show the comparaison with the first file\n");
cleanLine(); printf("\t\n");
cleanLine(); printf("\tInside Usage : \n");
cleanLine(); printf("\t\t[h] diplay/Hide Help\n");
cleanLine(); printf("\t\t[a] Go to the start of the files\n");
cleanLine(); printf("\t\t[z] Go to the end of the files (the first push is the File 1, the second push is the file 2) \n");
cleanLine(); printf("\t\t[q] Quit the curent program\n");
cleanLine(); printf("\t\t[s] Change the view of the propram of the size of interpretation (8/16/32/64 bits)\n");
cleanLine(); printf("\t\t[t] Change the interpretation of Data (hexedecimal, Signed Decimal, Unigned Decimal)\n");
cleanLine(); printf("\t\t[f] Find the first Error when comparing the two files\n");
cleanLine(); printf("\t\t[c] Calibrate the delta between the 2 file (fist element !=0)\n");
cleanLine(); printf("\t\t[UP] Go up (5 lines)\n");
cleanLine(); printf("\t\t[DOWN] Go down (5 lines)\n");
cleanLine(); printf("\t\t[LEFT] Go up (one screen)\n");
cleanLine(); printf("\t\t[RIGHT] Go down (one screen)\n");
cleanLine(); printf("\t\tAdd padding : \n");
cleanLine(); printf("\t\t\t[o] Add 1 Byte padding at the left file\n");
cleanLine(); printf("\t\t\t[O] Add 16 Bytes padding at the left file\n");
cleanLine(); printf("\t\t\t[p] Add 1 Byte padding at the right file\n");
cleanLine(); printf("\t\t\t[P] Add 16 Bytes padding at the right file\n");
cleanLine(); printf("\t\t\t[m] reset padding\n");
cleanLine(); printf("\t\tdiplay slot element\n");
cleanLine(); printf("\t\t\t[j] enable/disabe slot display\n");
cleanLine(); printf("\t\t\t[u] Decrement slot size -1 \n");
cleanLine(); printf("\t\t\t[U] Decrement slot size -10 \n");
cleanLine(); printf("\t\t\t[i] Increment slot size +1 \n");
cleanLine(); printf("\t\t\t[I] Increment slot size +10\n");
cleanLine(); printf("\t\t\t[k] Reset slot display\n");
cleanLine(); printf("\t\n");
cleanLine(); printf("\tCopyright: 2010 Edouard DUPIN, all right reserved\n");
cleanLine(); printf("\tLicense: GNU Lesser General Public License (LGPL) v3.0\n");
endLine();
}

View File

@ -50,5 +50,18 @@ int32_t GetNumberOfColomn(void);
void CleanDisplay(void);
// if 0 ==> disable ...
int32_t getSlotSize(void);
void setSlotSize(int32_t newSize);
void setSlotDisplayMode(bool enable);
bool getSlotDisplayMode(void);
void setHelpDisplay(bool enable);
bool getHelpDisplay(void);
void usage(void);
#endif