views:

32

answers:

2

I'm using uCsim to do unit test on SDCC projects.

In uCsim/S51, you can simulate serial line traffic by

s51 -s /dev/tty PROGRAM.ihx

or

s51 -S in=testdata.in,out=testdata.out PROGRAM.ihx

In the latter form, the data is immediately sent to the simulator which causes a lot of frames are lost. So instead of given the test data in plain file, using pipe instead:

s51 -S in=<(cat testdata.in),out=testdata.out PROGRAM.ihx

Now, how can I control the output baud from the `cat' utility? Or is there another utility I can use to output bits in a specific rate?

+1  A: 

The rate you feed the in= file is not how the rate is set. The simulator has no way of knowing when your application has initialized the serial port and is ready to read. You are probably missing data because the simulator feeds the simulated serial port before your serial initialization code has executed.

What you need to do is set up a fifo file with mkfifo (see the man page) then use that as your in= parameter. Then feed that fifo file with data after your simulated application is up and running.

Amardeep
A: 

Answer 1 is incorrect. Nobody "feeds" file's content to serial line. uCsim reads fromthe file when it is necessary. Baud rate is controlled by SFRs of timer and uart. When necessary count of ticks are simulated, one byte will be read from the file.

Dániel Drótos