def sys_transmit(self, cpu, fd, buf, count, tx_bytes):
data = []<EOL>if count != <NUM_LIT:0>:<EOL><INDENT>if not self._is_open(fd):<EOL><INDENT>logger.error("<STR_LIT>", fd)<EOL>return Decree.CGC_EBADF<EOL><DEDENT>if buf not in cpu.memory or (buf + count) not in cpu.memory:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>return Decree.CGC_EFAULT<EOL><DEDENT>if fd > <NUM_LIT:2> and self.files[fd].is_full():<EOL><INDENT>cpu.PC -= cpu.instruction.size<EOL>self.wait([], [fd], None)<EOL>raise RestartSyscall()<EOL><DEDENT>for i in range(<NUM_LIT:0>, count):<EOL><INDENT>value = Operators.CHR(cpu.read_int(buf + i, <NUM_LIT:8>))<EOL>if not isinstance(value, str):<EOL><INDENT>logger.debug("<STR_LIT>", fd)<EOL><DEDENT>data.append(value)<EOL><DEDENT>self.files[fd].transmit(data)<EOL>logger.info("<STR_LIT>" % (fd, buf, count, tx_bytes, '<STR_LIT>'.join([str(x) for x in data])))<EOL>self.syscall_trace.append(("<STR_LIT>", fd, data))<EOL>self.signal_transmit(fd)<EOL><DEDENT>if tx_bytes:<EOL><INDENT>if tx_bytes not in cpu.memory:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>return Decree.CGC_EFAULT<EOL><DEDENT>cpu.write_int(tx_bytes, len(data), <NUM_LIT:32>)<EOL><DEDENT>return <NUM_LIT:0><EOL>
transmit - send bytes through a file descriptor
          The  transmit system call writes up to count bytes from the buffer pointed
          to by buf to the file descriptor fd. If count is zero, transmit returns 0
          and optionally sets *tx_bytes to zero.

          :param cpu           current CPU
          :param fd            a valid file descriptor
          :param buf           a memory buffer
          :param count         number of bytes to send
          :param tx_bytes      if valid, points to the actual number of bytes transmitted
          :return: 0            Success
                   EBADF        fd is not a valid file descriptor or is not open.
                   EFAULT       buf or tx_bytes points to an invalid address.