Ga naar inhoud

quick & dirty aansturen parallelle poort


anoniem

Aanbevolen berichten

In Quickbasic was het met het commando OUT &H378,x mogelijk de parallelle poort aan te sturen. :D Nu zoek ik al weken naar een manier om dit onder VBA te doen. Nu kan ik natuurlijk wel een dosbox aanroepen waarin dit wordt gedaan (dat doe ik nu dus ook en dat werkt wel) maar dit geeft bijvoorbeeld timing problemen want VBA gaat door terwijl het programma in de dosbox nog draait. :-? Weet iemand een andere oplossing ?
Link naar reactie
Helaas... De enige methode om COM-poorten aan te spreken is met de Windows API. Poort openen als een normaal bestand, lezen en/of schrijven en ten slotte weer sluiten. Windows, vooral 2000 en XP, heeft een extra layer die de COM-poorten tegen direct schrijven beschermt. Immers, er kan een andere applicatie toevallig met de COM-poort bezig zijn. Kijk effe in de helpfiles naar de CreateFile API. Stukje voorbeeld:[code:1:2f7d928c57]/* A sample program to illustrate setting up a serial port. */ #include <windows.h> int main(int argc, char *argv[]) { DCB dcb; HANDLE hCom; BOOL fSuccess; char *pcCommPort = "COM2"; hCom = CreateFile( pcCommPort, GENERIC_READ | GENERIC_WRITE, 0, // comm devices must be opened w/exclusive-access NULL, // no security attributes OPEN_EXISTING, // comm devices must use OPEN_EXISTING 0, // not overlapped I/O NULL // hTemplate must be NULL for comm devices ); if (hCom == INVALID_HANDLE_VALUE) { // Handle the error. printf ("CreateFile failed with error %d.\n", GetLastError()); return (1); } // We will build on the current configuration, and skip setting the size // of the input and output buffers with SetupComm. fSuccess = GetCommState(hCom, &dcb); if (!fSuccess) { // Handle the error. printf ("GetCommState failed with error %d.\n", GetLastError()); return (2); } // Fill in the DCB: baud=57,600 bps, 8 data bits, no parity, and 1 stop bit. dcb.BaudRate = CBR_57600; // set the baud rate dcb.ByteSize = 8; // data size, xmit, and rcv dcb.Parity = NOPARITY; // no parity bit dcb.StopBits = ONESTOPBIT; // one stop bit fSuccess = SetCommState(hCom, &dcb); if (!fSuccess) { // Handle the error. printf ("SetCommState failed with error %d.\n", GetLastError()); return (3); } printf ("Serial port %s successfully reconfigured.\n", pcCommPort); return (0); }[/code:1:2f7d928c57]
Link naar reactie

Om een reactie te plaatsen, moet je eerst inloggen

Gast
Reageer op dit topic

×   Geplakt als verrijkte tekst.   Herstel opmaak

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

×
×
  • Nieuwe aanmaken...