Exemple #1
0
void scc_serial_win_fill_readbuf(int port, int space_left, double dcycs)      {
  byte tmp_buf[256];
  Scc     *scc_ptr;
  HANDLE host_handle;
  DWORD bytes_read;
  DWORD i;
  int ret;

  scc_ptr = &(scc_stat[port]);

  host_handle = scc_ptr->host_handle;
  if(host_handle == 0) {
    return;
  }

  /* Try reading some bytes */
  space_left = MIN(256, space_left);
  ret = ReadFile(host_handle, tmp_buf, space_left, &bytes_read, NULL);

  if(ret == 0) {
    printf("ReadFile ret 0\n");
  }

  if(ret && (bytes_read > 0)) {
    for(i = 0; i < bytes_read; i++) {
      scc_add_to_readbuf(port, tmp_buf[i], dcycs);
    }
  }

}
void
scc_serial_mac_fill_readbuf(int port, int space_left, double dcycs)
{
	byte	tmp_buf[256];
	Scc	*scc_ptr;
	int	fd;
	int	i;
	size_t	ret;

	scc_ptr = &(g_scc.scc_stat[port]);

	fd = (intptr_t)scc_ptr->host_handle;
	if(fd <= 0) {
		return;
	}

	/* Try reading some bytes */
	space_left = MIN(space_left, 256);
	ret = read(fd, tmp_buf, space_left);

	if(ret > 0) {
		for(i = 0; i < ret; i++) {
			scc_add_to_readbuf(port, tmp_buf[i], dcycs);
		}
	}
	
}