-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
何秀奇
committed
Jul 3, 2024
1 parent
e41786e
commit 9c0147c
Showing
16 changed files
with
641 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Com_CSSkin; | ||
using Commun.NetWork.MQTT; | ||
using CommunTools.Common; | ||
using CommunTools.Common.Twain; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace CommunTools | ||
{ | ||
/// <summary> | ||
/// LPT并口通讯 | ||
/// </summary> | ||
public partial class Frm_ComLPT : CSSkinMain | ||
{ | ||
public Frm_ComLPT() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public class PortControl // Import dll to project | ||
{ | ||
[DllImport("inpout32.dll", EntryPoint = "Out32")] | ||
public static extern void Output(int portAddress, int value); // decimal | ||
|
||
[DllImport("inpout32.dll", EntryPoint = "Inp32")] | ||
public static extern int Input(int portAddress); | ||
} | ||
|
||
static int portAddress = 0x378; // Typically, 0x378 is the address for LPT1 | ||
static int portDecData = 0xFF; | ||
|
||
private void btnInp_BtnClick(object sender, EventArgs e) | ||
{ | ||
// Read a value from the parallel port | ||
Console.WriteLine("Reading value from the parallel port..."); | ||
int value = PortControl.Input(portAddress); | ||
Console.WriteLine($"Value read from port: {value:X}"); | ||
} | ||
|
||
private void btnOut_BtnClick(object sender, EventArgs e) | ||
{ | ||
// Write a value to the parallel port | ||
Console.WriteLine("Writing value to the parallel port..."); | ||
PortControl.Output(portAddress, portDecData); // Sending 0xFF (all bits high) | ||
} | ||
} | ||
} |
Oops, something went wrong.