Jammen hvis du skal arbejde med porte, må og skal det gøres i C++.
- og en kommentar: Jeg lærte C++ programmering på bare 1 måned ved at læse en bog om C++. På den måde lærte jeg også meget bedre Pascal at kende. Du kan downloade en gratis C++ compiler på www.bloodshed.net Her er også kildekoden til C++ compileren (er lavet i Delphi).
Al Windows-programmering foregår i C++. Selv API-kaldene i dine Delphi-programmer.
Jo jeg kunen da godt give mig til at lære C++ og jeg tror gerne på at det egner sig til at arbejde med porte, men det er i et mindre skoleprojekt jeg skal og det er lidt stort at skulle til
men det er komponenter der skriver/læser bogstaver og det skal jeg ikke bruge. Jeg skal bruge noget hvor jeg direkte kan få at vide om der er strøm eller ej på et ben.
I såfald skal du kode ASSEMBLER. Jeg kender ikke lige ASM-koderne til det, men du kan sikkert finde nogle ældre bøger på biblioteket som handler om ASM.
poull>> jeg har plukket lidt i den medfølgende dokumentation, måske kan det give dig en idé om mulighederne -
ligefrem det at teste på et enkelt ben kan jeg ikke umiddelbart se - måske skal det kombineres med noget specialkode....
held og lykke med din søgen.
-------------------------------------------------
evBREAK - A break was detected on input. evCTS - The CTS (clear-to-send) signal changed state. evDSR - The DSR (data-set-ready) signal changed state. evERROR - A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY. evRING - A ring indicator was detected. evRLSD - The RLSD (receive-line-signal-detect) signal changed state. evRXCHAR - A character was received and placed in the input buffer. evRXFLAG - The event character was received and placed in the input buffer. The event character is specified in the device\'s DCB structure, which is applied to a serial port by using the SetCommState function. evTXEMPTY - The last character in the output buffer was sent. Available provider subtypes: PST_FAX FAX device PST_LAT LAT protocol PST_MODEM Modem device PST_NETWORK_BRIDGE Unspecified network bridge PST_PARALLELPORT Parallel port PST_RS232 RS-232 serial port PST_RS422 RS-422 port PST_RS423 RS-423 port PST_RS449 RS-449 port PST_SCANNER Scanner device PST_TCPIP_TELNET TCP/IP Telnet® protocol PST_UNSPECIFIED Unspecified PST_X25 X.25 standards
poull>> Her følger HELE dokumentationen: -------------------------------------------- ****************************************************************************** VARIAN ASYNC32 COMPONENT v1.25 (c) VARIAN SOFTWARE SERVICES NL 1996-1997 ALL RIGHTS RESERVED ******************************************************************************
TCOMM EXCEPTIONS ================ type ECommError = class(Exception) ErrorCode: Integer; end;
An ECommError exception contains an additional errorcode wich includes an windows system error result. This value is set to -1 when the error is handled by the component itself and no extra errorcode is available.
PUBLISHED PROPERTIES ====================
DeviceName
property DeviceName: string;
Name of communication device, Com1, Com2, Lpt1 etc. Can only be set when the port is not assigned (closed).
MonitorEvents
TCommEventState = (evBreak, evCTS, evDSR, evError, evRing, evRlsd, evRxChar, evRxFlag, evTxEmpty); TCommEventType = set of TCommEventState;
property MonitorEvents: TCommEventType;
Enable or disable certain system events.
evBREAK - A break was detected on input. evCTS - The CTS (clear-to-send) signal changed state. evDSR - The DSR (data-set-ready) signal changed state. evERROR - A line-status error occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY. evRING - A ring indicator was detected. evRLSD - The RLSD (receive-line-signal-detect) signal changed state. evRXCHAR - A character was received and placed in the input buffer. evRXFLAG - The event character was received and placed in the input buffer. The event character is specified in the device\'s DCB structure, which is applied to a serial port by using the SetCommState function. evTXEMPTY - The last character in the output buffer was sent.
Specifies the recommended size, in bytes, of the device\'s internal input buffer.
WriteBufSize
property WriteBufSize: Integer;
Specifies the recommended size, in bytes, of the device\'s internal output buffer.
CharsTimeout
property CharsTimeout: Integer;
Specifies the maximum time, in milliseconds, allowed to elapse between the arrival of two characters on the communications line. During a Read operation, the time period begins when the first character is received. If the interval between the arrival of any two characters exceeds this amount, the Read operation is completed and any buffered data is returned. A value of zero indicates that interval time-outs are not used.
Options
TCommOption = (coParityCheck, coDsrSensitivity, coIgnoreXOff, coErrorChar, coNullStrip); TCommOptions = set of TCommOption;
property Options: TCommOptions;
coParityCheck: Specifies whether parity checking is enabled. If this member is TRUE, parity checking is performed and errors are reported.
coDsrSensitivity: Specifies whether the communications driver is sensitive to the state of the DSR signal. If this member is TRUE, the driver ignores any bytes received, unless the DSR modem input line is high.
coIgnoreXoff: Specifies whether transmission stops when the input buffer is full and the driver has transmitted the XoffChar character. If this member is TRUE, transmission continues after the input buffer has come within XoffLim bytes of being full and the driver has transmitted the XoffChar character to stop receiving bytes. If this member is FALSE, transmission does not continue until the input buffer is within XonLim bytes of being empty and the driver has transmitted the XonChar character to resume reception.
coErrorChar: Specifies whether bytes received with parity errors are replaced with the character specified by the ErrorChar member. If this member is TRUE and the fParity member is TRUE, replacement occurs.
coNullStrip: Specifies whether null bytes are discarded. If this member is TRUE, null bytes are discarded when received.
EventChars
XonChar property XonChar: char; Specifies the value of the XON character for both transmission and reception
XoffChar property XoffChar: char; Specifies the value of the XOFF character for both transmission and reception.
fcNone No flowcontrol fsCTS Rts/Cts flowcontrol fsDTR Specifies the DTR (data-terminal-ready) flow control. fsSoftware Xon/Xoff flowcontrol fcDefault Use system settings
METHODS AND PUBLIC PROPERTIES =============================
Enabled
function Enabled: Boolean;
Describes the component/device state, true=Open, false=Closed
Open
procedure Open;
Opens the communications device and does all the needed configurations. Open must be called in order to access the comport. If an invalid device handle is requested, one of the following errorcodes is returned.
2 File not found. 3 Invalid file name. 4 Too many open files. 5 Access denied. 100 EOF. 101 Disk full. 106 Invalid input.
Close
procedure Close;
Close the communications device.
Write
function Write(const Buf; Count: Integer): Integer;
Buf is any variable, Count is an expression of type Integer. Write writes Count or fewer bytes to the com port from memory, starting at the first byte occupied by Buf. The actual number of bytes written (less than or equal to Count) is returned in it\'s Result. If a write operations fails it returns -1.
Read
function Read(var Buf; Count: Integer): Integer;
Buf is any variable, Count is an expression of type Integer. Read reades Count or fewer bytes from the com port. The actual number of bytes read (less than or equal to Count) is returned in it\'s Result. If a read operations fails it returns -1. Never try to read bytes manually by specifying the count parameter yourself. Use the Count parameter returned in \"RxCharEvent\".
InQueCount
function InQueCount: Integer;
Number of bytes in the ReadBuffer.
OutQueCount
function OutQueCount: Integer;
Number of bytes in the WriteBuffer. When all bytes are sent, an OnTxEmpty event is triggerd.
PurgeIn
procedure PurgeIn;
Remove all pending characters from the inputbuffer (read).
PurgeOut
procedure PurgeOut;
Remove all pending characters from the outputbuffer (write).
SetDTRState
procedure SetDTRState(State: Boolean);
False - Clears the DTR (data-terminal-ready) signal. True - Sends the DTR (data-terminal-ready) signal.
SetRTSState
procedure SetRTSState(State: Boolean);
False - Clears the RTS (request-to-send) signal. True - Sends the RTS (request-to-send) signal.
SetBreakState
procedure SetBREAKState(State: Boolean);
False - Restores character transmission and places the transmission line in a nonbreak state. True - Suspends character transmission and places the transmission line in a break state. Note that this extended function does not flush data that has not been transmitted.
SetXONState
procedure SetXONState(State: Boolean);
False - Causes transmission to act as if an XOFF character has been received. True - Causes transmission to act as if an XON character has been received.
CTS
property CTS: Boolean;
True - The CTS (clear-to-send) signal is on.
DSR
property DSR: Boolean;
True - The DSR (data-set-ready) signal is on.
RING
property RING: Boolean;
True - The ring indicator signal is on.
RLSD
property RLSD: Boolean;
True - The RLSD (receive-line-signal-detect) signal is on.
Handle
property Handle: THandle;
Reference to the internal devicehandle (Readonly property)
ProviderSubtype
property ProviderSubtype: Integer;
Device Id. Use the added GetProviderSubTypeName function in order to get a string representation of the type of device currently opened.
Available provider subtypes: PST_FAX FAX device PST_LAT LAT protocol PST_MODEM Modem device PST_NETWORK_BRIDGE Unspecified network bridge PST_PARALLELPORT Parallel port PST_RS232 RS-232 serial port PST_RS422 RS-422 port PST_RS423 RS-423 port PST_RS449 RS-449 port PST_SCANNER Scanner device PST_TCPIP_TELNET TCP/IP Telnet® protocol PST_UNSPECIFIED Unspecified PST_X25 X.25 standards
EVENTS ======
OnBreak
property OnBreak: TNotifyEvent;
A break was detected on input.
OnCTS
property OnCTS: TNotifyEvent;
The CTS (clear-to-send) signal changed state.
OnDSR
property OnDSR: TNotifyEvent;
The DSR (data-set-ready) signal changed state.
OnRing
property OnRing: TNotifyEvent;
A ring indicator was detected.
OnRLSD
property OnRLSD: TNotifyEvent;
The RLSD (receive-line-signal-detect) signal changed state.
CE_BREAK The hardware detected a break condition. CE_DNS Windows 95 only: A parallel device is not selected. CE_FRAME The hardware detected a framing error. CE_IOE An I/O error occurred during communications with the device. CE_MODE The requested mode is not supported, or the hFile parameter is invalid. If this value is specified, it is the only valid error. CE_OOP Windows 95 only: A parallel device signaled that it is out of paper. CE_OVERRUN A character-buffer overrun has occurred. The next character is lost. CE_PTO Windows 95 only: A time-out occurred on a parallel device. CE_RXOVER An input buffer overflow has occurred. There is either no room in the input buffer, or a character was received after the end-of-file (EOF) character. CE_RXPARITY The hardware detected a parity error. CE_TXFULL The application tried to transmit a character, but the output buffer was full.
A character was received and placed in the input buffer. Count defines the number of bytes received.
OnRxFlag
property OnRxFlag: TNotifyEvent;
The event character was received and placed in the input buffer. The event character is specified in the device\'s DCB structure, which is applied to a serial port by using the SetCommState function.
jeg har ikke fået det til at du, hvilket betød at jeg måtte lave det i java, for der kunne jeg godt.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.