sending image over serial port

8 views (last 30 days)
Josephine
Josephine on 4 Dec 2013
Answered: Josephine on 4 Dec 2013
hi i want to send a .bmp file over a serial port from pc. do i need some kind of conversion of the file into something that can be sent serially? and what is it? the output file should still be bitmap because i am going to send it to fpga for image processing. thank you in advance.

Answers (2)

Walter Roberson
Walter Roberson on 4 Dec 2013
You do not need to convert the file if the other end is able to decode the file. But probably what the other end will need will be a data matrix, so you will need to convert the .bmp file into a data matrix by using imread() on it.
You can send the numeric data array over the serial port by using fwrite(). Serial ports are normally able to handle 8 bit bytes, and that should be the case for the situation you are in.
You will need to create a protocol so that the fpga knows how much data to expect and what the dimensions are -- unless those are invariant, of course.
As I come from the days when sending data over a serial port often involved whistling into a telephone, I always worry about the possibility of bytes getting lost or corrupted when sent by serial, so I tend to think in terms of protocols for detecting errors and resending the damaged portion, and so on. Remember, the faster you send the data, the more risk there is of data being lost.
How big are these images? And why are you processing them on an FPGA? Have you worked out how long it is going to take you to send the images? And how long to transmit the answer back? Couldn't that time be better used in just going ahead and computing whatever the FPGA would have been used for?
In the majority of circumstances that involve needing an FPGA, I would recommend against using a serial port to transmit the data. Use a DAQ (Data Acquisition Device) with a DIO (Digital Input/Output), or use ethernet or the like. You can get FPGA kits that have ethernet or Zigbies on-board.

Josephine
Josephine on 4 Dec 2013
thank you for your response mr.walter. i am really new to image processing and is currently researching and studying about it. i have so much to learn about fpga also including those which you have mentioned. i will try what you suggested.
what i am trying to do now is send an image over serial port in a loopback connection before i try it in fpga. my test image is 900kb, i used my laptop camera to capture the image and saved it as .bmp. i'm afraid sending file this large will take sometime and so, that's another problem.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!