Author Topic: Development of interface software for the miniRDS in C#  (Read 22915 times)

SteveyD

  • Newbie
  • *
  • Posts: 24
Development of interface software for the miniRDS in C#
« on: July 02, 2011, 10:11:46 am »
Greetings

Anyone else out here working on a C# version of the mrdsio.dll example?

Code: [Select]
procedure ConnectionSetup(ConMode, PortNum: integer; Bidirectional, Slow: boolean); using the Delphi pascal works fine for the LPT ports.

converting it to C#

Code: [Select]
[DllImport("mrdsio.dll")]
        public static extern void ConnectionSetup(int ConMode, int PortNum, bool Bidirectional, bool Slow);

PortNum = 0x378
PortNum = 378
PortNum = 888

None of the different PortNum defines will access the LPT1 in C#

Anyone know the reason?

SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #1 on: July 02, 2011, 10:47:18 am »
Sorted it out..  I was missing the Inpout32.dll  in the directory.

On to the next step.


SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #2 on: July 05, 2011, 09:07:25 pm »
Jan

mrdsio.dll

Does the dll return a C-style array or SafeArray?

I've got everything working in C# except the Receive function

 

Jan

  • Hero Member
  • *****
  • Posts: 1058
Re: Development of interface software for the miniRDS in C#
« Reply #3 on: July 06, 2011, 09:04:50 am »
It's probably no one from the two options.

If you can pass the array in the Send function, it should be possible to get it also using the Receive function as the array format is still the same.

The Delphi array declaration

Code: [Select]
TData = array [0..255] of byte;
is probably equal to

Code: [Select]
BYTE TData[255];
However if you know better format for the array to pass, the mrdsio.dll can be updated as it is still possible at this stage.

SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #4 on: July 06, 2011, 12:22:18 pm »
Thanks Jan

The current Array function in Delphi is the best method at this point.

I've encountered some difficulty calling the Array from the mrdsio.dll in C#

Its most likely something I'm not doing correctly in the Receive routine as the Send routine works fine.

SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #5 on: July 28, 2011, 02:35:09 am »
Jan

can you take a look at the Receive function of your example1.pas 

Procedure  TForm.Button5Click(Sender:TObject);

"if not(CheckBox1.Checked) then
begin StatusBar1.SimpleText:='Bidirectional operation not allowed';exit;end; "


IF the CheckBox1 is checked, then Bidirectional operation is allowed.
IF the CheckBox1 is not checked, then Bidirectional operation is not allowed.


Your Procedure checks the CheckBox1 and if it is checked, will continue on to receive the data.
(Bidirectional operation IS allowed, and required to complete the procedure as the code is written)

If the CheckBox1 is not checked, then you get the trap of "Bidirectional operation not allowed" with an exit. which is the exact opposite logic of what you want.


Is the trap even needed?  if so, you should change;

"if not (CheckBox1.Checked) then"


Steve









Jan

  • Hero Member
  • *****
  • Posts: 1058
Re: Development of interface software for the miniRDS in C#
« Reply #6 on: July 28, 2011, 10:15:32 am »
It is surely right as it is, you cannot read any data in uni-directional mode, so -> exit.

SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #7 on: July 30, 2011, 02:46:51 pm »
I see, Bi-directional operation is REQUIRED.

therefore the trap is correct, and the CheckBox1 must be checked.

The error is the message;

StatusBar1.SimpleText:="Bidirectional operation not allowed"

should be

StatusBar1.SimpleText:= "Bidirectional operation required"



On another note,  Which is returned in the Receive function,  TData as a byte array  or Result: Output as a string?


Jan

  • Hero Member
  • *****
  • Posts: 1058
Re: Development of interface software for the miniRDS in C#
« Reply #8 on: July 30, 2011, 03:26:49 pm »
You may take the example sources and modify them as required.

SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #9 on: September 14, 2011, 05:39:24 pm »
Has anyone come up with a working example for using the Receive function in VB or C#?
I've converted and tested all the functions except Receive. Its still giving me problems.

function Receive (Adr, Len : Integer); TData; stdcall;


SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #10 on: September 19, 2011, 01:19:06 am »
Solved!

I had a Bool declaration backwards

SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #11 on: October 17, 2011, 09:15:20 am »
Jan

I've been encountering application crashes when I use the "Disconnect" button on your example.exe

This occurs in WinXP Sp3, as well as Win7 Sp1.

The error always occurs in the same memory location on the mrdsio.dll

I'm trying to get a screen shot to post.

Has anyone else reported this problem?

Steve

Jan

  • Hero Member
  • *****
  • Posts: 1058
Re: Development of interface software for the miniRDS in C#
« Reply #12 on: October 17, 2011, 09:29:38 am »
Make sure you have the latest version http://pira.cz/rds/mrdsio.zip
This works stable for me using any combination of OS or settings.

SteveyD

  • Newbie
  • *
  • Posts: 24
Re: Development of interface software for the miniRDS in C#
« Reply #13 on: October 17, 2011, 10:38:37 am »
Yes, I'm using Dll version 0.98

Application Error

Exception EAccessViolation in module mrdsio.dll at 000038C4,
Access violation at addres 075938C4 in module 'mrdsio.dll'.
Read of address 00000000.

Jan

  • Hero Member
  • *****
  • Posts: 1058
Re: Development of interface software for the miniRDS in C#
« Reply #14 on: October 17, 2011, 11:59:50 am »
Is your example file actual too?