Esempio n. 1
0
BOOL FormReply(void)
{
    BYTE    cbIMsg;

    cbIMsg = GetMsgLen();
    if ((cbIMsg == 0) || (cbIMsg > m_commPort.cbRcvd) || (cbIMsg > IBUF_SIZE))
    {
        return false;
    }
    // Check CRC
    if (QryCrc8(m_IBuffer) != m_IBuffer[cbIMsg-1])
    {
        return false;
    }
    // Analyze message
    switch (m_IBuffer[0])
    {
    case 0x0E:
        dn1022_read();
        break;
    case 0x10:
        dn1022_wirte();
        break;
    case 0x85:
    case 0x86:
        io_in();
        break;
     default:
        return false;
    }

    return true;
}
Esempio n. 2
0
/*
 *	Port modify
 */
static void do_port(char *s)
{
	register BYTE port;
	static char nv[LENCMD];
	extern BYTE io_out(), io_in();

	while (isspace((int)*s))
		s++;
	port = exatoi(s);
	printf("%02x = %02x : ", port, io_in(port));
	fgets(nv, sizeof(nv), stdin);
	if (isxdigit((int)*nv))
		io_out(port, (BYTE) exatoi(nv));
}
Esempio n. 3
0
int io_in(struct io_file *f,int pos,void *i,int len) {
	int end = pos + len;
	if (0 == len) return pos;
	if (NULL == f || -1 == pos) return -1;
	if (NULL == i) return pos + len;
	if (remap(f,pos,len)) return -1;
	if (unbuffer(f)) return -1;

	if (pos >= f->file_size && checksize(f)) return -1;
	if (pos >= f->file_size) {
/* TODO: fill with zeroes instead */
		fputs("read: EOF\n",stderr);
		return -1;
	}

	if (end > (int)(f->map_offset + f->map_size))
		end = f->map_offset + f->map_size;
	if (end > f->file_size)
		end = f->file_size;
	memcpy(i,pos - f->map_offset + (char *) f->map,end - pos);
	return io_in(f,end,end - pos + (char *) i,len + pos - end);
}