Click here to Skip to main content
14,239,386 members

C / C++ / MFC

 
QuestionUsing fstream with USB Serial Port Pin
OscardelaGrouch6-Jul-18 20:53
memberOscardelaGrouch6-Jul-18 20:53 
AnswerRe: Using fstream with USB Serial Port Pin
Richard MacCutchan6-Jul-18 23:25
protectorRichard MacCutchan6-Jul-18 23:25 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 6:39
memberOscardelaGrouch7-Jul-18 6:39 
GeneralRe: Using fstream with USB Serial Port Pin
Richard MacCutchan7-Jul-18 6:52
protectorRichard MacCutchan7-Jul-18 6:52 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 6:55
memberOscardelaGrouch7-Jul-18 6:55 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 8:21
memberOscardelaGrouch7-Jul-18 8:21 
GeneralRe: Using fstream with USB Serial Port Pin
speedbump997-Jul-18 12:59
memberspeedbump997-Jul-18 12:59 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 13:18
memberOscardelaGrouch7-Jul-18 13:18 
speedbump99 wrote:
For what it's worth, are you sure your serial port parameters match?

Yes. I can send data back and forth with a terminal program.
I have modified the programs like this ..
void APP_Wixel_IO_Test_Tasks(void)
{
    APP_ESUART_Tasks();
    if (CmdReady == 1)
    {
        CmdReady = 0;                               // reset flag
        RXBufCnt = 0;                               // reset RX Buffer count
        utoa(TXBuf, Cnt, 10);                       // convert cnt into a string
        strcat(TXBuf, "\n");                        // add NULL to end of string
        WriteESUARTDataMsg(TXBuf, strlen(TXBuf));   // send command back to ESUART
        Cnt++;                                      // increment cnt
    }
}

and this ..
int main(int argc, char** argv)
{
    fstream COMPORT;
    int number;
    int x = 0;
    char c;

    while(1)    // only works for first input. run again and missed one reply
    {
        COMPORT.open("/dev/ttyACM0");
        if (COMPORT.is_open())
        {
            cout << "Hit <Enter> to send command, <S> to Stop .." << endl;
            cin.get(c);
            if ((c == 's' || c == 'S')) 
            {
                COMPORT.close();
                return 0;
            }
            COMPORT << "UPLOAD NEW MAP\n";
            COMPORT >> number;
            cout << "number = " << number;
            cout << endl;
        }
        COMPORT.close();
    }
    return 0;
}

I get this response ..
Hit <Enter> to send command, <S> to Stop ..

number = 0
Hit <Enter> to send command, <S> to Stop ..

number = 2
Hit <Enter> to send command, <S> to Stop ..

number = 4
Hit <Enter> to send command, <S> to Stop ..

number = 6
Hit <Enter> to send command, <S> to Stop ..

number = 8
Hit <Enter> to send command, <S> to Stop ..
s

I cannot figure why the cnt goes to two times instead of one.
I would like to not be limited to just sending numbers back from the PIC.
I think I am doing things "pretty' much correctly, but??
Any thoughts?
OdlG
GeneralRe: Using fstream with USB Serial Port Pin
speedbump997-Jul-18 14:51
memberspeedbump997-Jul-18 14:51 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 15:46
memberOscardelaGrouch7-Jul-18 15:46 
GeneralRe: Using fstream with USB Serial Port Pin
speedbump997-Jul-18 16:10
memberspeedbump997-Jul-18 16:10 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch8-Jul-18 8:08
memberOscardelaGrouch8-Jul-18 8:08 
GeneralRe: Using fstream with USB Serial Port Pin
speedbump998-Jul-18 11:55
memberspeedbump998-Jul-18 11:55 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch9-Jul-18 8:49
memberOscardelaGrouch9-Jul-18 8:49 
AnswerRe: Using fstream with USB Serial Port Pin
OscardelaGrouch8-Jul-18 10:57
memberOscardelaGrouch8-Jul-18 10:57 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch9-Jul-18 8:52
memberOscardelaGrouch9-Jul-18 8:52 
AnswerRe: Using fstream with USB Serial Port Pin
Jochen Arndt10-Jul-18 3:31
mveJochen Arndt10-Jul-18 3:31 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch10-Jul-18 9:53
memberOscardelaGrouch10-Jul-18 9:53 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch10-Jul-18 18:43
memberOscardelaGrouch10-Jul-18 18:43 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt10-Jul-18 21:09
mveJochen Arndt10-Jul-18 21:09 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch11-Jul-18 17:40
memberOscardelaGrouch11-Jul-18 17:40 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt11-Jul-18 21:16
mveJochen Arndt11-Jul-18 21:16 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch12-Jul-18 18:42
memberOscardelaGrouch12-Jul-18 18:42 
GeneralRe: Using fstream with USB Serial Port Pin
Jochen Arndt12-Jul-18 20:59
mveJochen Arndt12-Jul-18 20:59 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch14-Jul-18 7:51
memberOscardelaGrouch14-Jul-18 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.