Hello

I'm stuck on a CS1501 compile error for this line

value = PortAccess.Out(PortNum + 1);

its supposed to change the Port from 888 to 889

Am I over complicating it?

It's late, I can no longer see the forest for all these trees.. =P

public bool inportbit()  // Reads input bit from the LPT port

        {
            bool result;
            byte value;
            int value2;
            value = PortAccess.Out(PortNum + 1);
            value2 = value;
            if (((value2 - 128) >= 0))
            {
                value2 = value2 - 128;
            }
            if (((value2 - 64) >= 0))
            {
                value2 = value2 - 64;
            }
            if (((value2 - 32) >= 0))
            {
                result = true;
            }
            else
            {
                result = false;
            }
            return result;
        }

Recommended Answers

All 4 Replies

Can you please specify the argument type of out() method and PortNum?

public class PortAccess
        {
            [DllImport("inpout32.dll", EntryPoint = "Out32")]
            public static extern void Out(int adress, int value);

            [DllImport("inpout32.dll", EntryPoint = "Inp32")]
            public static extern int In(int address);

            internal static byte In()
            {
                throw new NotImplementedException();
            }
        }
ParallelSetupDialog dialog = new ParallelSetupDialog(this.m_portAddress);
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.m_portAddress = dialog.PortAddress;
                this.m_setupData.SetInteger(this.m_setupNode, "address", this.m_portAddress);
            }
private ushort PortNum;

Out method has two arguments.

int value=65;
PortAccess.Out(PortNum + 1,value);

After a few hours of sleep I realized I wanted to READ, not Write the PortBit.

Changing

value = PortAccess.Out(PortNum + 1);

to

value = PortAccess.In(PortNum + 1);

This also changed the

byte value;
 to
int value;

This cleared the compiler errors, but now the result is " ACK bit Not Received"
from this section.

public void SendStop(bool __Break)
                {
                    PortAccess.Out(PortNum,0);
                    Thread.Sleep(p);
                    PortAccess.Out(PortNum,8);
                    Thread.Sleep(p);
                    PortAccess.Out(PortNum,16+8);
                    Thread.Sleep(p);
                    if (__Break)
                    {
                        if ((ack))
                        {
                            MessageBox.Show("ACK bit not received.", Application.ProductName, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                        }
                    }
                }

Getting closer, but still not there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.