Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- #include <fcntl.h> // Contains file controls like O_RDWR
- #include <errno.h> // Error integer and strerror() function
- #include <termios.h> // Contains POSIX terminal control definitions
- #include <unistd.h> // write(), read(), close()
- using namespace std;
- class PowerSupplyOp {
- public:
- float V_conversion=1.812*10**(-3); //voltage conversion factor
- float I_conversion=4.980*10**(-3); //current conversion factor (mA)
- char STX[] = "02"; //start of text - fixed
- char ETX[] = "03"; //end of text - fixed
- char CR[] = "0D"; //delimiter - fixed
- char convert(char command) //convert command to hexadecimal and get a bytearray sum??
- {
- }
- char checksum(char sum_command, double sum_voltage) //necessary for communication with power supply
- {
- }
- void start() //Connect to the Power supply
- {
- ser = open("/dev/ttyUSB0", O_RDWR);
- if (ser <0){
- printf("Error %i from open: %s\n", errno, strerror(errno));
- }
- // Create new termios struc to set configuration
- struct termios tty;
- memset(&tty, 0, sizeof tty);
- // Read in existing settings, and handle any error
- if(tcgetattr(serial_port, &tty) != 0) {
- printf("Error %i from tcgetattr: %s\n", errno, strerror(errno));
- }
- tty.c_cflag |= PARENB; // Set parity bit, enabling parity
- tty.c_cflag &= ~CSTOPB; // One stop bit used in communication
- tty.c_cflag |= CS8; // 8 bits per byte
- // Set baud rate
- cfsetispeed(&tty, B38400);
- cfsetospeed(&tty, B38400);
- // Save tty settings, also checking for error
- if (tcsetattr(serial_port, TCSANOW, &tty) != 0) {
- printf("Error %i from tcsetattr: %s\n", errno, strerror(errno));
- }}
- void stop() //disconnect from the Power supply
- {
- close(ser)
- }
- char convert()
- std::vector<double> getVolt() //outputs the Voltage for the four channels (same value for all channels), similar to getValue
- {
- }
- std::vector<double> getCurr() //outputs the Current for the four channels (same value for all channels)
- {
- }
- void loadConfig(double u0) //sets the voltage, similar to setValue
- {
- }
- };
- int main () {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement