sprog.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __SPROG_H__
  2. #define __SPROG_H__
  3. #include <serial.h>
  4. #define array_size(x) (sizeof(x)/sizeof(*x))
  5. struct sprog_data {
  6. int size;
  7. int alloc;
  8. unsigned char *data;
  9. };
  10. struct sprog_family {
  11. void *(*setup)(struct serial_device *dev);
  12. void (*init)(void *arg);
  13. void (*exec)(void *arg, const struct sprog_data *d);
  14. void (*write)(void *arg, const struct sprog_data *d);
  15. void (*close)(void *arg);
  16. };
  17. extern const char sprog_version[];
  18. void sprog_communicate(const struct sprog_family *fam, const struct sprog_data *d, int mode, const char *port, int baud);
  19. int sprog_getline(char *buf, int len, int timeout);
  20. int sprog_waitdata(struct serial_device *port, int timeout);
  21. void sprog_info(const char *text, ...);
  22. void sprog_error(const char *text, ...);
  23. void sprog_sleep(int msec);
  24. void sprog_load(struct sprog_data *d, const char *path);
  25. void sprog_alloc_data(struct sprog_data *d, int len);
  26. void sprog_append_data(struct sprog_data *d, const char *data, int len);
  27. void sprog_progress(int progress, int total);
  28. #endif