S
Stu Lock
Hi,
I am trying to write a script that sends a code to a COM port to open a till
draw. The code at the bottom of the page (written in C) is what the
suppliers sent as an example. I have used the SerialPort class in .Net 2.0
to try and send the same message. So far I have this on a button click:
-------------------------------------------------------------
Dim ComPort As New SerialPort("COM6", 9600)
ComPort.Parity = Parity.None
ComPort.StopBits = StopBits.One
ComPort.DataBits = 8
ComPort.Handshake = Handshake.None
ComPort.Open()
ComPort.Write("0x07")
ComPort.Close()
ComPort.Dispose()
-------------------------------------------------------------
The code runs without error (unless I run it on a machine that doesn't have
COM6 installed on it) - but nothing happens.
Am I passing the command in the right format?
Any ideas?
Thanks in advance,
Stu
-------------------------------------------------------------
The C code example sent:
-------------------------------------------------------------
#include <dos.h>
#include <stdio.h>
#include <bios.h>
#include <process.h>
//
#define CacheDrawerStatusPort 0x404a
#define CacheDrawerCtrlPort 0x404d
#define CacheDrawerStatusBitOffset 0x10
#define CacheDrawerCtrlBitOffset 0x80
//
void ShowCacheDrawerStatus(void);
//
void main(void)
{
unsigned char CacheDrawerCtrlBit;
int Key;
//
ShowCacheDrawerStatus();
printf("Press Space key to toggle cache drawer control bit.\n");
printf("Press Ctrl+Q key to exit.\n");
while(1)
{
while(!bioskey(1));
Key=bioskey(0);
Key&=0x00ff;
switch(Key)
{
case 0x20:
CacheDrawerCtrlBit=inportb(CacheDrawerCtrlPort);
CacheDrawerCtrlBit^=CacheDrawerCtrlBitOffset;
outportb(CacheDrawerCtrlPort,CacheDrawerCtrlBit);
delay(1000);
ShowCacheDrawerStatus();
break;
case 0x11:
exit(0);
break;
}
}
}
void ShowCacheDrawerStatus(void)
{
unsigned char CacheDrawerStatusBit;
CacheDrawerStatusBit=inportb(CacheDrawerStatusPort);
if((CacheDrawerStatusBit&CacheDrawerStatusBitOffset) ==
CacheDrawerStatusBitOffset)
printf("Cache drawer is closed now.\n");
else
printf("Cache drawer is opened now.\n");
}
I am trying to write a script that sends a code to a COM port to open a till
draw. The code at the bottom of the page (written in C) is what the
suppliers sent as an example. I have used the SerialPort class in .Net 2.0
to try and send the same message. So far I have this on a button click:
-------------------------------------------------------------
Dim ComPort As New SerialPort("COM6", 9600)
ComPort.Parity = Parity.None
ComPort.StopBits = StopBits.One
ComPort.DataBits = 8
ComPort.Handshake = Handshake.None
ComPort.Open()
ComPort.Write("0x07")
ComPort.Close()
ComPort.Dispose()
-------------------------------------------------------------
The code runs without error (unless I run it on a machine that doesn't have
COM6 installed on it) - but nothing happens.
Am I passing the command in the right format?
Any ideas?
Thanks in advance,
Stu
-------------------------------------------------------------
The C code example sent:
-------------------------------------------------------------
#include <dos.h>
#include <stdio.h>
#include <bios.h>
#include <process.h>
//
#define CacheDrawerStatusPort 0x404a
#define CacheDrawerCtrlPort 0x404d
#define CacheDrawerStatusBitOffset 0x10
#define CacheDrawerCtrlBitOffset 0x80
//
void ShowCacheDrawerStatus(void);
//
void main(void)
{
unsigned char CacheDrawerCtrlBit;
int Key;
//
ShowCacheDrawerStatus();
printf("Press Space key to toggle cache drawer control bit.\n");
printf("Press Ctrl+Q key to exit.\n");
while(1)
{
while(!bioskey(1));
Key=bioskey(0);
Key&=0x00ff;
switch(Key)
{
case 0x20:
CacheDrawerCtrlBit=inportb(CacheDrawerCtrlPort);
CacheDrawerCtrlBit^=CacheDrawerCtrlBitOffset;
outportb(CacheDrawerCtrlPort,CacheDrawerCtrlBit);
delay(1000);
ShowCacheDrawerStatus();
break;
case 0x11:
exit(0);
break;
}
}
}
void ShowCacheDrawerStatus(void)
{
unsigned char CacheDrawerStatusBit;
CacheDrawerStatusBit=inportb(CacheDrawerStatusPort);
if((CacheDrawerStatusBit&CacheDrawerStatusBitOffset) ==
CacheDrawerStatusBitOffset)
printf("Cache drawer is closed now.\n");
else
printf("Cache drawer is opened now.\n");
}