Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Migrate a dll from 32bit to 64bit OS Pin
«_Superman_»25-Mar-10 21:00
professional«_Superman_»25-Mar-10 21:00 
GeneralRe: Migrate a dll from 32bit to 64bit OS Pin
002comp25-Mar-10 22:16
002comp25-Mar-10 22:16 
GeneralRe: Migrate a dll from 32bit to 64bit OS Pin
«_Superman_»25-Mar-10 22:19
professional«_Superman_»25-Mar-10 22:19 
GeneralRe: Migrate a dll from 32bit to 64bit OS Pin
002comp26-Mar-10 1:39
002comp26-Mar-10 1:39 
AnswerRe: Migrate a dll from 32bit to 64bit OS Pin
sashoalm25-Mar-10 22:39
sashoalm25-Mar-10 22:39 
GeneralRe: Migrate a dll from 32bit to 64bit OS Pin
002comp26-Mar-10 0:04
002comp26-Mar-10 0:04 
Questionmsflexgrid headers Pin
Member 59031025-Mar-10 19:41
Member 59031025-Mar-10 19:41 
QuestionHow do I Parse the Serial Data Recieved from the Serial Port Pin
Jimmie Sypolt25-Mar-10 17:19
Jimmie Sypolt25-Mar-10 17:19 
I'm using the following code for Visual C++ 2008 to open the serial port and read lines output by a GPS. The received data is separated by comma's and I need to write only certain data, not the whole line.

I have a sense that I should be looking at the "Console::WriteLine(message);" code and doing something like WriteByte or StringBuilder or something. I haven't written code since 2003/4 and it seems to have change a whole lot since then.

Hopefully, I've explained my problem successfully (I can clarify, if needed). Any help anyone can provide would be great as I've been pulling my hair out for a few days.

Thanks.


#include "stdafx.h"
#using <System.dll>
using namespace System;
using namespace System::IO::Ports;
using namespace System::Threading;

public ref class PortChat
{
private:
    static bool _continue;
    static SerialPort^ _serialPort;

public:
    static void Main()
    {
        String^ name;
        String^ message;
        StringComparer^ stringComparer = StringComparer::OrdinalIgnoreCase;
        Thread^ readThread = gcnew Thread(gcnew ThreadStart(PortChat::Read));

        // Create a new SerialPort object with default settings.
        _serialPort = gcnew SerialPort();

        // Set the read/write timeouts
        _serialPort->ReadTimeout = 500;
        _serialPort->WriteTimeout = 500;

        _serialPort->Open();
        _continue = true;
        readThread->Start();

        Console::WriteLine("Type QUIT to exit");
        while (_continue)
        {
            message = Console::ReadLine();
            if (stringComparer->Equals("quit", message))
            {
                _continue = false;
            }
            else
            {
                _serialPort->WriteLine(
                    String::Format("<{0}>: {1}", name, message) );
            }
        }
        readThread->Join();
        _serialPort->Close();
    }
    static void Read()
    {
        while (_continue)
        {
            try
            {
                String^ message = _serialPort->ReadLine();
                Console::WriteLine(message);
            }
            catch (TimeoutException ^) { }
        }
    }
};
int main()
{
    PortChat::Main();
 
}

AnswerRe: How do I Parse the Serial Data Recieved from the Serial Port Pin
loyal ginger25-Mar-10 18:08
loyal ginger25-Mar-10 18:08 
AnswerRe: How do I Parse the Serial Data Recieved from the Serial Port Pin
KingsGambit25-Mar-10 18:33
KingsGambit25-Mar-10 18:33 
GeneralRe: How do I Parse the Serial Data Recieved from the Serial Port Pin
Jimmie Sypolt25-Mar-10 20:15
Jimmie Sypolt25-Mar-10 20:15 
GeneralRe: How do I Parse the Serial Data Recieved from the Serial Port Pin
KingsGambit25-Mar-10 20:36
KingsGambit25-Mar-10 20:36 
QuestionRe: How do I Parse the Serial Data Recieved from the Serial Port Pin
David Crow26-Mar-10 4:57
David Crow26-Mar-10 4:57 
Questionconstructor and destructor [modified] Pin
zakria8125-Mar-10 15:43
zakria8125-Mar-10 15:43 
AnswerRe: constructor and destructor Pin
hanq_3891013025-Mar-10 16:51
hanq_3891013025-Mar-10 16:51 
AnswerRe: constructor and destructor Pin
David Crow26-Mar-10 4:59
David Crow26-Mar-10 4:59 
QuestionDisplay current time as Label control text Pin
Lucidation25-Mar-10 12:14
Lucidation25-Mar-10 12:14 
AnswerRe: Display current time as Label control text Pin
Peter_in_278025-Mar-10 16:23
professionalPeter_in_278025-Mar-10 16:23 
GeneralRe: Display current time as Label control text Pin
loyal ginger25-Mar-10 18:10
loyal ginger25-Mar-10 18:10 
AnswerRe: Display current time as Label control text Pin
BIJU Manjeri25-Mar-10 18:00
BIJU Manjeri25-Mar-10 18:00 
AnswerRe: Display current time as Label control text Pin
loyal ginger25-Mar-10 18:15
loyal ginger25-Mar-10 18:15 
GeneralRe: Display current time as Label control text Pin
Cool_Dev26-Mar-10 3:35
Cool_Dev26-Mar-10 3:35 
GeneralRe: Display current time as Label control text Pin
Lucidation26-Mar-10 5:31
Lucidation26-Mar-10 5:31 
QuestionHow to create database & tables on another machine?? Pin
Ed K25-Mar-10 9:50
Ed K25-Mar-10 9:50 
QuestionRe: How to create database & tables on another machine?? Pin
David Crow25-Mar-10 10:46
David Crow25-Mar-10 10:46 

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.