Contents
Aaron Klapheck
% Transfer a message file 26-Aug-08 clear, clc, home fprintf('The date and time: %s \n \n', datestr(now))
The date and time: 26-Aug-2008 10:43:41
Program Information
% Purpose % The purpose of this program is to set up direct communication to the % Basic Stamp and to recieve information from it. % Execution % How this works is that a serial comunication port is opened and data is % read from it using the fscanf command. This information is then converted % into text format and displayed. % Users % For those who wish to use this code to send messages of their own the % following information may prove useful. The parts of this code that would % change depending on individuals software and hardware setup are % followed by a marking; marking: **(may need to change)**.
Recieve message from BS2
port = 'COM4'; % **(may need to change)** s = serial(port); % Select COM port get(s) % list properties of COM port fopen(s) % Open COM port for reading [message, leangth] = fscanf(s); %Recived lone LF from Boe-Bot % Repeate the while loop below untill information is being sent. When there is % information being sent its length will always be two or greater. x is % used because sometimes a stable communication is not established (due to % an inproper connection, falty coding, etc.) so x will keep the loop from % repeating infinitly in that case. while leangth < 2; x = 0; x = x + 1; if x == 30; leangth = 30; end [message, leangth] = fscanf(s); %Recived text from Boe-Bot end text1_char = message; message = cellstr(text1_char) fclose(s) delete(s) clear s
ByteOrder = littleEndian
BytesAvailable = 0
BytesAvailableFcn =
BytesAvailableFcnCount = 48
BytesAvailableFcnMode = terminator
BytesToOutput = 0
ErrorFcn =
InputBufferSize = 512
Name = Serial-COM4
ObjectVisibility = on
OutputBufferSize = 512
OutputEmptyFcn =
RecordDetail = compact
RecordMode = overwrite
RecordName = record.txt
RecordStatus = off
Status = closed
Tag =
Timeout = 10
TimerFcn =
TimerPeriod = 1
TransferStatus = idle
Type = serial
UserData = []
ValuesReceived = 0
ValuesSent = 0
SERIAL specific properties:
BaudRate = 9600
BreakInterruptFcn =
DataBits = 8
DataTerminalReady = on
FlowControl = none
Parity = none
PinStatus = [1x1 struct]
PinStatusFcn =
Port = COM4
ReadAsyncMode = continuous
RequestToSend = on
StopBits = 1
Terminator = LF
message =
'Hello, this is a message from your Boe-Bot'