This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Loading text files

I've just started playing with MCB2130 and did some
examples.

Now I would like to enable / clear leds with external file.
So, I would write a text file, each line would be a led address that would stay on for some time, then it would clear that and enable the second one... till it reaches the end of this file.

My biggest problem is
- how to load a file into memory (I was looking at voice player example, so by using flash.ini file, but is this the right way for simple text files??? Do I need to convert them to some other format?)

- how to read such file (Is it always at same memory address, how to determine it's length...)

I'm not sure if this is the right approach to this problem at all, but instructions needs to be in a file.

Parents
  • Something is bothering me with serial communication.
    What is the minimum delay between sending bits via serial?

    I'm using java and if I don't pause for small time (e.g. 100 ms), then characters are not properly received and program on mcb board doesn't work (this happens from any program).

    Also how can I do multiple things at once - e.g. blinking leds and at the same time listen continuosly for incoming data from com port?

Reply
  • Something is bothering me with serial communication.
    What is the minimum delay between sending bits via serial?

    I'm using java and if I don't pause for small time (e.g. 100 ms), then characters are not properly received and program on mcb board doesn't work (this happens from any program).

    Also how can I do multiple things at once - e.g. blinking leds and at the same time listen continuosly for incoming data from com port?

Children
  • Use interrupt-driven serial communication. Many samples available if you google for it.

    Then your main loop can run a loop that checks if it is time to change state of a diode or if the input buffer have one or more received characters to process.

    If you poll the serial port, then you must poll it often enough that you will react and fetch a received character before the next character arrives - normally around 10 times the baudrate. With 9600 baud, it takes about 10ms for each character to be transmitted. Polling at a slower speed will result in one or more lost character. With interrupt-driven communication, the size of the receive buffer will allow the main loop to take longer time to check if there are received data, without any loss. Sometimes, it can be enough to have a 8 or 16-character receive buffer to solve any problems with lost characters.