// anything to read, any errors?
ClearCommError(hVtrPort, &dwErrorMask, &comstat);
if(dwErrorMask)
return;
// make sure we don't read more
// than we have room for!
if(comstat.cbInQue > (DWORD) sizeof(bytemp))
nToRead = sizeof(bytemp);
else
nToRead = comstat.cbInQue;
// any?
if(nToRead == 0)
return;
// get the response
nRc = ReadFile(hVtrPort, (void *) bytemp,
nToRead, &ReturnedByteCount, NULL);
// sort out the return stuff...
if(nRc == FALSE)
return;
// NAK?if((*bytemp 0x011) && (*(bytemp + 1) 0x012))
// vtr doesn't like the command
// some error handling might be nice
return;
// ACK?if((*bytemp 0x010) && (*(bytemp + 1) 0x001))
// command ok, no return data
return;
#define SONY_DF 0x040
BYTE bymask[] = {0x03f, 0x07f, 0x07f, 0x03f};
// machine typeif((*bytemp 0x012) && (*(bytemp + 1) 0x011))
{
// process machine type
// this displays the return as xx yy
wsprintf(sztemp, "%2.2x %2.2x",
bytemp[2],
bytemp[3]);
SetDlgItemText(hWnd, IDC_MAIN_TIME, sztemp);
return;
}
// status/time code?
if((*bytemp & 0x0f0) == 0x070)
{
// status?
if(*(bytemp + 1) == 0x020)
{
// show the status
// in the real world, you'll have to decode
// the bits' what's of importance to you
// displays the first 4 bytes of returned data
wsprintf(sztemp, "%2.2x %2.2x %2.2x %2.2x ...",
bytemp[2],
bytemp[3],
bytemp[4],
bytemp[5]);
SetDlgItemText(hWnd, IDC_MAIN_TIME, sztemp);
return;
}
else
{
// bravo! maybe something useful
// some kind of time code...
// in our case, it can only be time
// this displays the time as 00:00:00:00 N
wsprintf(sztemp, "%2.2x:%2.2x:%2.2x:%2.2x %c",
(bytemp[5] & bymask[3]),
(bytemp[4] & bymask[2]),
(bytemp[3] & bymask[1]),
(bytemp[2] & bymask[0]),
(char)
(((bytemp[2] & SONY_DF) == 0)? 'N' : 'D'));
SetDlgItemText(hWnd, IDC_MAIN_TIME, sztemp);
}
}
Fin code-------------------------------------------------------------