Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Object pointer as method argument Pin
_Flaviu8-Jul-18 19:57
_Flaviu8-Jul-18 19:57 
NewsRe: Object pointer as method argument Pin
Richard MacCutchan9-Jul-18 3:01
mveRichard MacCutchan9-Jul-18 3:01 
AnswerRe: Object pointer as method argument Pin
CPallini8-Jul-18 20:59
mveCPallini8-Jul-18 20:59 
GeneralRe: Object pointer as method argument Pin
_Flaviu9-Jul-18 5:45
_Flaviu9-Jul-18 5:45 
QuestionMFC Static Library Project Pin
Richard Andrew x647-Jul-18 16:04
professionalRichard Andrew x647-Jul-18 16:04 
AnswerRe: MFC Static Library Project Pin
Victor Nijegorodov7-Jul-18 21:48
Victor Nijegorodov7-Jul-18 21:48 
GeneralRe: MFC Static Library Project Pin
Richard Andrew x648-Jul-18 3:26
professionalRichard Andrew x648-Jul-18 3:26 
QuestionUsing fstream with USB Serial Port Pin
OscardelaGrouch6-Jul-18 20:53
OscardelaGrouch6-Jul-18 20:53 
Hello everyone,
I'm kinda new to writing application programs for a PC, a Linux one at that, so I hope this isn't a stupid question. Wink | ;)
I am rather experienced at writing C programs for Microchip PICs. I need a PC application to interface with a PIC project, it will up load information to the PIC from the PC using a pair of Wixel modules. They are basically a USB to RF or RF to Serial bridge. I have them working (one connected to the PC, one connected to the PIC) using a terminal program. I can send data back and forth just fine.
I am now trying to send and receive data using a C++ application. The sending from the PC to the PIC works just fine also. The problem I am having is getting data from the PIC to the PC Application.

This is the application code ..
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>

using namespace std;

/*
 * 
 */
int main(int argc, char** argv)
{
    fstream COMPORT;

    char line[256];
    streamsize lim = 256;
    char c;

    COMPORT.open("/dev/ttyACM0");
    
    while(1)    // only works for first input. run again and missed one reply
    {
        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.getline(line, lim);
            cout << "Line =" << line;
            cout << "Response=" << c;
            cout << endl;
        }
    }
    COMPORT.close();
    return 0;
}


The PIC code, if that helps ..
void APP_Wixel_IO_Test_Tasks(void)
{
    APP_ESUART_Tasks();
    if (CmdReady == 1)
    {
        CmdReady = 0;                               // reset flag
        RXBufCnt = 0;                     // reset RX Buffer count command
        utoa(TXBuf, Cnt, 10);
        strcat(TXBuf, "\n");
        WriteESUARTDataMsg(TXBuf, strlen(RXBuf));   // send command back to ESUART
        Cnt++;                                      // increment cnt
    }
}


Basically all the PIC code does is send back the 'cnt' variable when it gets data from the PC.
The
COMPORT.getline(line, lim);
doesn't work right. The first time I run it, it kinda works, but resending the data back to the PIC gets no response ..

Hit <Enter> to send command, <S> to Stop ..

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

Response=

Hit <Enter> to send command, <S> to Stop ..

Response=

Hit <Enter> to send command, <S> to Stop ..

Response=

Hit <Enter> to send command, <S> to Stop ..


I've tried everything I can think of. Like I said, data out
COMPORT << "UPLOAD NEW MAP\n";
works fine. Data in does not.
Thanks Wink | ;)
OtG
AnswerRe: Using fstream with USB Serial Port Pin
Richard MacCutchan6-Jul-18 23:25
mveRichard MacCutchan6-Jul-18 23:25 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 6:39
OscardelaGrouch7-Jul-18 6:39 
GeneralRe: Using fstream with USB Serial Port Pin
Richard MacCutchan7-Jul-18 6:52
mveRichard MacCutchan7-Jul-18 6:52 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 6:55
OscardelaGrouch7-Jul-18 6:55 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 8:21
OscardelaGrouch7-Jul-18 8:21 
GeneralRe: Using fstream with USB Serial Port Pin
mo14927-Jul-18 12:59
mo14927-Jul-18 12:59 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 13:18
OscardelaGrouch7-Jul-18 13:18 
GeneralRe: Using fstream with USB Serial Port Pin
mo14927-Jul-18 14:51
mo14927-Jul-18 14:51 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch7-Jul-18 15:46
OscardelaGrouch7-Jul-18 15:46 
GeneralRe: Using fstream with USB Serial Port Pin
mo14927-Jul-18 16:10
mo14927-Jul-18 16:10 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch8-Jul-18 8:08
OscardelaGrouch8-Jul-18 8:08 
GeneralRe: Using fstream with USB Serial Port Pin
mo14928-Jul-18 11:55
mo14928-Jul-18 11:55 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch9-Jul-18 8:49
OscardelaGrouch9-Jul-18 8:49 
AnswerRe: Using fstream with USB Serial Port Pin
OscardelaGrouch8-Jul-18 10:57
OscardelaGrouch8-Jul-18 10:57 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch9-Jul-18 8:52
OscardelaGrouch9-Jul-18 8:52 
AnswerRe: Using fstream with USB Serial Port Pin
Jochen Arndt10-Jul-18 3:31
professionalJochen Arndt10-Jul-18 3:31 
GeneralRe: Using fstream with USB Serial Port Pin
OscardelaGrouch10-Jul-18 9:53
OscardelaGrouch10-Jul-18 9:53 

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.