areaDetector  3-5-0
EPICS areaDetector framework
sw_com_port.h
Go to the documentation of this file.
1 
10 /*
11  * Include files.
12  */
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string>
17 #include "time.h"
18 #include "comportInterface.h"
19 //#include "ccd_exception.h"
20 #include "logfile.h"
21 #include <queue>
22 /*
23  * Double incluson protection.
24  */
25 #ifndef _SW_COM_PORT_H
26 #define _SW_COM_PORT_H
27 
28 /*
29  * Class for
30  */
31 
32 class sw_com_port : public comportInterface {
33  public:
34  sw_com_port(char *name,log_file *lf_);
35  ~sw_com_port();
36  /*
37  * ports we can write to
38  */
39 
40  virtual void open(void);
41  virtual void open(int baud, int parity, int nbits, int nstop);
42 
43  virtual void open(int baud, int parity, int nbits, int nstop, int rdtimeout);
44 
45  virtual void write(unsigned char *buffer, int length);
46  virtual void read(unsigned char *buffer, int length);
47  virtual void write(unsigned char c);
48  virtual unsigned char read(void);
49  virtual void close(void);
50  virtual void flush(void);
51  virtual void clearPipe();
52 
53  virtual void setPortName(char *n);
54 
55  virtual void wait(int us);
56 
57  // for timing things. call tic. toc returns time in s since last tic.
58  virtual void tic();
59  virtual double toc();
60 
61  protected:
62  bool is_open;
63 
65 
66  char INBUFFER[500];
67 
68  char OUTBUFFER[20];
69 
70  int bytes_read; // Number of bytes read from port
71 
72  int bytes_written; // Number of bytes written to the port
73 
74  //HANDLE comport; // Handle COM port
75 
76  int bStatus;
77 
78  //DCB comSettings; // Contains various port settings
79 
80  //COMMTIMEOUTS CommTimeouts;
81 
82  char port_name[64];
84 
85  std::queue<unsigned char> *myqueue;
86 
87 };
88 
89 #endif
int bStatus
Definition: sw_com_port.h:76
int bytes_read
Definition: sw_com_port.h:70
int bytes_written
Definition: sw_com_port.h:72
Interface to a com port, on a grabber.
Definition: comportInterface.h:24
name
Definition: makeDbAndEdl.py:232
virtual void setPortName(char *n)
Set port name like COM1 or etc.
Definition: sw_com_port.cpp:39
char OUTBUFFER[20]
Definition: sw_com_port.h:68
virtual double toc()
read stop watch in sec.
Definition: sw_com_port.cpp:190
virtual void write(unsigned char *buffer, int length)
Write mem buffer of byes, num bytes to ser port, flush.
Definition: sw_com_port.cpp:101
virtual void close(void)
close ser port.
Definition: sw_com_port.cpp:149
virtual void flush(void)
Definition: sw_com_port.cpp:142
std::queue< unsigned char > * myqueue
Definition: sw_com_port.h:85
bool is_open
Definition: sw_com_port.h:62
virtual void tic()
Start a stop watch.
Definition: sw_com_port.cpp:181
char port_name[64]
Definition: sw_com_port.h:82
Class LOG_FILE.
Definition: logfile.h:38
virtual unsigned char read(void)
read 1 byte from ser port.
Definition: sw_com_port.cpp:116
double elapsedtime
Definition: sw_com_port.h:64
sw_com_port(char *name, log_file *lf_)
Class for general serial port.
Definition: sw_com_port.cpp:16
log_file * lf
Definition: sw_com_port.h:83
~sw_com_port()
Destructior.
Definition: sw_com_port.cpp:28
virtual void clearPipe()
read ser port until no data left.
Definition: sw_com_port.cpp:157
char INBUFFER[500]
Definition: sw_com_port.h:66
double currenttime
Definition: sw_com_port.h:64
virtual void open(void)
OPen com port with default settings.
Definition: sw_com_port.cpp:77
virtual void wait(int us)
Waait in a for loop.
Definition: sw_com_port.cpp:166
Class for general serial port.
Definition: sw_com_port.h:32