Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h" // for VS (must be first)
- #include <iostream>
- using namespace std;
- int main(int argc, char *argv[])
- {
- ////// TASK 2, Convert negative integer.
- // // Write a small program that defines a negative integer(between - 1 and -255),
- // // converts it to a positive value and then displays it on the console window.
- //
- // int negativeNumber = -30;
- // int positiveNumber = abs(negativeNumber);
- // cout << positiveNumber << endl;
- ////// TASK 3, check argument is numerical
- for (int x = 0; x < strlen(argv[1]); x++) {
- char ch = argv[1][x];
- if (!isdigit(ch)) {
- cout << "Error: non digit found in argument 1." << endl;
- break;
- }
- }
- //for (portb = 0; portb <= 100; portb++)
- //{
- // _itoa_s(portb, val_string, 10);
- // strcpy_s(command, BaseWriteCommand); // reset the command array with the BaseWriteCommand string
- // strcat_s(command, val_string); // append the value to write to portb to the Command string
- // // pipe code that sends out the current Command stored in the command variable
- // fpipe = (FILE*)_popen(command, "r");
- // if (fpipe != NULL)
- // {
- // while (fgets(line, sizeof(line), fpipe))
- // { //do nothing, or print out debug data
- // cout << "Debug line:" << line; // print out OUSB data
- // }
- // _pclose(fpipe);
- // }
- // else cout << "Error, problems with pipe!\n";
- // cout << endl;
- // portb++;
- //}
- // //// TASK 5, READ PINC
- //// Declare common variables
- // char command[255] = {}; // array that will hold the OUSB commands
- // char line[255] = {}; // array to hold received data from the OUSB board
- // FILE *fpipe; // file variable, see text book module 11.
- //
- // char ReadCommand[] = "ousb -r io PINC"; // String containing the OUSB read command
- //
- // strcpy_s(command, ReadCommand); // reset the command array with the BaseWriteCommand string
- //
- // // pipe code that sends out the current Command stored in the command variable
- // fpipe = (FILE*)_popen(command, "r");
- // if (fpipe != NULL)
- // {
- // while (fgets(line, sizeof(line), fpipe))
- // { //do nothing, or print out debug data
- // cout << line; // print out OUSB data
- // }
- // _pclose(fpipe);
- // }
- // else cout << "Error, problems with pipe!\n";
- //
- // cout << endl;
- //
- //
- // //// TASK 6, READ PINC AND APPEND
- //// Declare common variables
- // char command[255] = {}; // array that will hold the OUSB commands
- // char line[255] = {}; // array to hold received data from the OUSB board
- // FILE *fpipe; // file variable, see text book module 11.
- // int lineInt;
- //
- // char ReadCommand[] = "ousbsim2 -r io PINC"; // String containing the OUSB read command
- //
- // strcpy_s(command, ReadCommand); // reset the command array with the BaseWriteCommand string
- //
- // // pipe code that sends out the current Command stored in the command variable
- // fpipe = (FILE*)_popen(command, "r");
- // if (fpipe != NULL)
- // {
- // while (fgets(line, sizeof(line), fpipe))
- // { //do nothing, or print out debug data
- // // cout << line; // print out OUSB data
- // lineInt = (int)atoi(line);
- // }
- // _pclose(fpipe);
- // }
- // else cout << "Error, problems with pipe!\n";
- //
- // cout << lineInt + 12;
- //
- // cout << endl;
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement