Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I've been trying to send a command from my c++ program to epos2 70/10 through RS232 (not using the DLL provided), but I only receive two 79 witch is 'O' meaning ok, but after that I receive nothing, and the the motor doesn't work(not spining). What's wrong?
please help.
Here is my code:

C++
#include "stdafx.h"
#include<iostream>
using namespace std;
using namespace System::IO::Ports;
using namespace System;

typedef unsigned char byte;

int main()
{
	SerialPort^ sp=gcnew SerialPort("COM1",115200);
	
	sp->Open();
	if(sp->IsOpen)
		cout<<"port opened."<<endl;

	array<byte>^bytes = gcnew array<byte>(8);

	bytes[0]=0x10;
	bytes[1]=0x01;
	bytes[2]=0x03;
	bytes[3]=0x20;
	bytes[4]=0x01;
	bytes[5]=0x02;
	bytes[6]=0x88;
	bytes[7]=0xA8;

	sp->Write(bytes, 0, 8);
	cout<<sp->ReadByte()<<"first\n";
	cout<<sp->ReadByte()<<"second\n";
	cout<<sp->ReadByte()<<"third\n";
	//cout<<s<<"\n";

    return 0;
}
Posted

It seems that your program exits after reading bytes from the device. Should epos2 70/10 continue to run even after your program exits? I mean what does command you're sending tell epos2 70/10, To 'spin regardless app is running' or 'spin till app is running'?

If it does mean something like 'spin till app is running', try putting getch() before return 0;
 
Share this answer
 
Comments
mehdi_k 15-Apr-13 2:54am    
EPOS2 should return 2 bytes witch are 97 or 'O', that it returns it, but after that it should return another bytes sp->ReadByte()<<"third\n"; that it doesn't and stucks. the command I found in an example.
I'm getting the same problem. Have you solved it?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900