César, como lo prometido es deuda, alla vamos.
A la aplicación todavía le faltan algunos pequeños retoques, pero te comento.La comunicación por el PParalelo, la logre de la siguiente manera, te envió el fuente .cpp para que te resulte más facil.
//---------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Puerto.h"
//------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//-------------------------------------------
void TForm1::outp(unsigned short dir,unsigned short dato)
{
_DX=dir;
_AX=dato;
__emit__(0xEE);//Código de la instrucción OUT
}
//--------------------------------------
unsigned int TForm1::inp(unsigned short dir)
{
_DX=dir;
__emit__(0xEC);//Código de la instrucción IN
return(_AL);
}
//-------------------------------------------void __fastcall TForm1::SalirClick(TObject *Sender)
{
exit(0);
}
//----------------------------------------
void __fastcall TForm1::EnviarClick(TObject *Sender)
{
outp(0x378,(unsigned short)StrToInt(Edit1->Text));
}
//---------------------------------------
void __fastcall TForm1::RecibirClick(TObject *Sender)
{Edit2->Text=IntToStr(inp(0x378));
}
También te envió el .h
#ifndef PuertoH
#define PuertoH
//-------------------------------------------#include <vcl\Classes.hpp>
#include <vcl\Controls.hpp>
#include <vcl\StdCtrls.hpp>
#include <vcl\Forms.hpp>
#include <vcl\ExtCtrls.hpp>
//-------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
///*TPanel *Panel1;
TGroupBox *GroupBox1;
TButton *Salir;
TGroupBox *GroupBox2;
TGroupBox *GroupBox3;
TLabel *Label1;
TLabel *Label2;
TEdit *Edit1;
TButton *Enviar;
TButton *Recibir;
TEdit *Edit2;
TButton *Refresca_Dato;*///
void __fastcall SalirClick(TObject *Sender);
void __fastcall EnviarClick(TObject *Sender);
void __fastcall RecibirClick(TObject *Sender);
void __fastcall Refresca_DatoClick(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
// ¡¡¡¡Agregar aquí!!!!
void outp(unsigned short dir,unsigned short dato);
unsigned int inp(unsigned short dir);
};
//-------------------------------------------extern TForm1 *Form1;
//--------------------------------------
#endif
Comentario: El bloque que he marcado con ///* */// depende de la aplicación, en mi caso tiene varias cosas. Pero con poner 2 Button(Enviar y Recibir), 2 Edit, en Edit1 escribes el Dato y en Edit2 recoges el valor de Retorno, desde luego cuando pulses el Button Recibir.
Imagino que sepas que lo complicado, es que hay que tener mucho cuidado, si es que vas a utilizar el programa para actuar sobre otros elementos(LED,motores;etc),pues necesitas una interface enter Puerto y elemento e incluso esta ultima tiene que ser bien diseñada por que si no, adios puertito de mi vida, puedes sobre cargar el puerto.
Yo lo he provado, con LED.
Espero haber podido ayudarte, si precisas algo más, con mucho gusto.
Saludos