mirror of
https://github.com/ariejan/i6502.git
synced 2024-05-28 22:41:34 +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
|
// Implements io.Reader, for external programs to read TX'ed data from
|
||||||
// the serial output.
|
// the serial output.
|
||||||
func (a *Acia6551) Read(p []byte) (n int, err error) {
|
func (a *Acia6551) Read(p []byte) (n int, err error) {
|
||||||
a.txEmpty = true
|
if a.txEmpty {
|
||||||
copy(p, []byte{a.tx})
|
return 0, nil
|
||||||
// TODO: Handle txInterrupt
|
} else {
|
||||||
return 1, nil
|
a.txEmpty = true
|
||||||
|
copy(p, []byte{a.tx})
|
||||||
|
// TODO: Handle txInterrupt
|
||||||
|
return 1, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements io.Writer, for external programs to write to the
|
// 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)
|
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) {
|
func TestAciaWriteByteAndReader(t *testing.T) {
|
||||||
a := AciaSubject()
|
a := AciaSubject()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user