123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- #include <unistd.h>
- #include <limits.h>
- #include <errno.h>
- #include "../tools/getoptv.h"
- #include "../tools/putoptv.h"
- #include "../tools/number.h"
- #include "../tools/error.h"
- #include "../tools/files.h"
- #include "../tools/types.h"
- #ifndef MAKEFILE
- #include "../tools/getoptv.c"
- #include "../tools/putoptv.c"
- #include "../tools/version.c"
- #include "../tools/uintspec.c"
- #include "../tools/todigit.c"
- #include "../tools/hexstring.c"
- #include "../tools/hexdecode.c"
- #include "../tools/error.c"
- #endif
- #define TM_VERBOSE (1 << 0)
- #define TM_SILENCE (1 << 1)
- #define OFFSET 0x24BF
- #define LENGTH 50
- int main (int argc, char const * argv [])
- {
- static char const * optv [] =
- {
- "",
- "file [file] [...] [> stdout]",
- "print GPIO information",
- (char const *) (0)
- };
- #ifndef __GNUC__
- #pragma pack (push, 1)
- #endif
- typedef struct __packed EventBlock
- {
- uint8_t EvtPriorityId;
- uint8_t EvtId;
- uint8_t BehId [3];
- uint16_t ParticipatingGPIOs;
- uint8_t EventAttributes;
- uint8_t RSVD [3];
- }
- EventBlock;
- #ifndef __GNUC__
- #pragma pack (pop)
- #endif
- struct EventBlock EventBlockArray [50];
- file_t fd;
- signed c;
- optind = 1;
- while ((c = getoptv (argc, argv, optv)) != -1)
- {
- switch (c)
- {
- default:
- break;
- }
- }
- argc -= optind;
- argv += optind;
- while ((argc) && (* argv))
- {
- if ((fd = open (* argv, O_BINARY|O_RDONLY)) == -1)
- {
- error (0, errno, "Can't open %s", * argv);
- }
- else if (lseek (fd, OFFSET, SEEK_SET) != OFFSET)
- {
- error (0, errno, "Can't seek %s", * argv);
- close (fd);
- }
- else if (read (fd, &EventBlockArray, sizeof (EventBlockArray)) != sizeof (EventBlockArray))
- {
- error (0, errno, "Can't read %s", * argv);
- close (fd);
- }
- else
- {
- for (c = 0; c < LENGTH; c++)
- {
- struct EventBlock * EventBlock = (&EventBlockArray [c]);
- char string [10];
- printf ("EvtPriorityId %3d ", EventBlock->EvtPriorityId);
- printf ("EvtId %3d ", EventBlock->EvtId);
- printf ("BehId %s ", hexstring (string, sizeof (string), EventBlock->BehId, sizeof (EventBlock->BehId)));
- printf ("ParticipatingGPIOs %3d ", EventBlock->ParticipatingGPIOs);
- printf ("EventAttributes %3d ", EventBlock->EventAttributes);
- printf ("\n");
- }
- close (fd);
- }
- argc--;
- argv++;
- }
- return (0);
- }
|