mirror of
https://github.com/ariejan/i6502.git
synced 2025-04-12 01:37:05 +00:00
Acia Tx return nothing when there is no new data
This commit is contained in:
parent
f934c5cdf6
commit
3747d8ce41
12
acia6551.go
12
acia6551.go
@ -95,10 +95,14 @@ func (a *Acia6551) statusRegister() byte {
|
||||
// Implements io.Reader, for external programs to read TX'ed data from
|
||||
// the serial output.
|
||||
func (a *Acia6551) Read(p []byte) (n int, err error) {
|
||||
a.txEmpty = true
|
||||
copy(p, []byte{a.tx})
|
||||
// TODO: Handle txInterrupt
|
||||
return 1, nil
|
||||
if a.txEmpty {
|
||||
return 0, nil
|
||||
} else {
|
||||
a.txEmpty = true
|
||||
copy(p, []byte{a.tx})
|
||||
// TODO: Handle txInterrupt
|
||||
return 1, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Implements io.Writer, for external programs to write to the
|
||||
|
@ -36,6 +36,18 @@ func TestAciaReset(t *testing.T) {
|
||||
assert.Equal(t, 0, a.controlData)
|
||||
}
|
||||
|
||||
func TestAciaReaderWithTxEmpty(t *testing.T) {
|
||||
a := AciaSubject()
|
||||
|
||||
// Nothing to read
|
||||
assert.True(t, a.txEmpty)
|
||||
|
||||
value := make([]byte, 1)
|
||||
bytesRead, _ := a.Read(value)
|
||||
|
||||
assert.Equal(t, 0, bytesRead)
|
||||
}
|
||||
|
||||
func TestAciaWriteByteAndReader(t *testing.T) {
|
||||
a := AciaSubject()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user