Code covered by the BSD License  

Highlights from
SerialWrite Mex

4.0

4.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 5.41 KB File ID: #23780

SerialWrite Mex

by Kevin Barry

 

15 Apr 2009

SerialWrite is written in C and allows you to write to a serial or com port.

| Watch this File

File Information
Description

SerialWrite is written in C and allows you to write to a serial port without using the Matlab SERIAL interface. The reason for this is that Matlab's SERIAL often crashes/"Times out". The code is short and easy to understand for future modifications, or it can be used as is.

serial_write('open', 'COM40', 57600);
serial_write('write', 'Hello');
serial_write('write_line', ', World'); % Adds the \r\n
serial_write('close');

MATLAB release MATLAB 7.5 (R2007b)
Other requirements Windows
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
20 Apr 2009 Dagnir F

Thank you for this code.
I was looking for an alternative to the "serial" given by Matlab because it is too slow/cannot compile to mex.
Your code is faster and indeed easy to understand.
Yet being new to Matlab I don't understand where does the WriteFile function come from. Likewise, is there a ReadFile function one could use in the same way ?

20 Apr 2009 Kevin Barry

WriteFile is part of the Windows API.

Check out ReadFile here: http://msdn.microsoft.com/en-us/library/aa365467(VS.85).aspx

I'm normally program Linux or Mac, so I don't know this stuff well (I learned about WriteFile when I wrote SerialWrite)

10 Aug 2009 Hyon Lim

Thank you.
This will be very helpful to make s-function

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
serial Kevin Barry 15 Apr 2009 09:40:59
com Kevin Barry 15 Apr 2009 09:40:59
comm Kevin Barry 15 Apr 2009 09:40:59
com port Kevin Barry 15 Apr 2009 09:40:59
com1 Kevin Barry 15 Apr 2009 09:40:59
baud Kevin Barry 15 Apr 2009 09:40:59
serial io Kevin Barry 15 Apr 2009 09:40:59
fopen Kevin Barry 15 Apr 2009 09:40:59
serial port Kevin Barry 15 Apr 2009 09:40:59
rs232 Kevin Barry 15 Apr 2009 12:11:51
com port David R. 03 Jun 2009 04:51:20

Contact us at files@mathworks.com