meterComm.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * meterComm.h
  3. *
  4. * Created on: 2021/6/4
  5. * Author: foluswen
  6. */
  7. #ifndef HEADER_METERCOMM_H_
  8. #define HEADER_METERCOMM_H_
  9. #include <sys/time.h>
  10. #include <sys/timeb.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <sys/types.h>
  14. #include <sys/ioctl.h>
  15. #include <sys/socket.h>
  16. #include <sys/ipc.h>
  17. #include <sys/shm.h>
  18. #include <sys/shm.h>
  19. #include <sys/mman.h>
  20. #include <linux/wireless.h>
  21. #include <arpa/inet.h>
  22. #include <netinet/in.h>
  23. #include <unistd.h>
  24. #include <stdarg.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <unistd.h>
  28. #include <fcntl.h>
  29. #include <termios.h>
  30. #include <errno.h>
  31. #include <errno.h>
  32. #include <string.h>
  33. #include <time.h>
  34. #include <ctype.h>
  35. #include <ifaddrs.h>
  36. #include <signal.h>
  37. typedef struct METER_INFO
  38. {
  39. double presetVoltage; // resolution: 1.000v
  40. double presentCurrent; // resolution: 1.000a
  41. double presentPower; // resolution: 1.000kw
  42. double totlizeImportEnergy; // resolution: 1.000kwh
  43. double totlizeExportEnergy; // resolution: 1.000kwh
  44. uint8_t LinkStatus; // 0 = unknow ,1 = link , 2 miss link
  45. }Meter_Info;
  46. enum METER_MODEL
  47. {
  48. METER_MODEL_LEM_L18005A=0,
  49. };
  50. extern void meterInitialize(uint8_t model);
  51. extern void meterApiAssign(uint8_t meterIndex);
  52. extern int readVoltage(Meter_Info *meter_info);
  53. extern int readCurrent(Meter_Info *meter_info);
  54. extern int readPower(Meter_Info *meter_info);
  55. extern int readEnergy(Meter_Info *meter_info);
  56. extern unsigned char meterModel;
  57. extern char meterApiAddress[];
  58. #endif /* HEADER_METERCOMM_H_ */