I am a new comer to MongooseIM.
I have setup the server and am able to exchange messages between two users.
Now I am trying to setup the server to enable MUCs.
I have enabled mod_muc in ejabberd.conf file.
On executing the create_room command, the error says :
mongooseimctl create_room test
command “create_room” not known
Is there something that i may be missing.
I looked up ejabberdctl command "create_room" not known , but the solution there didnt work out. Is there something that is specific to MongooseIM?
Enabled modules :
%%%. =======
%%%' MODULES
%%
%% Modules enabled in all ejabberd virtual hosts.
%% For list of possible modules options, check documentation.
%%
{modules,
[
{mod_admin_extra, [{submods, [node, accounts, sessions, vcard,
roster, last, private, stanza, stats]}]},
{mod_adhoc, []},
{mod_disco, []},
{mod_last, []},
{mod_stream_management, [
% default 100
% size of a buffer of unacked messages
% {buffer_max, 100}
% default 1 - server sends the ack request after each stanza
% {ack_freq, 1}
% default: 600 seconds
% {resume_timeout, 600}
]},
{mod_muc, [
{host, "muc.#HOST#"},
{access, all},
{access_create, all}
]},
{mod_muc_log,
[
{outdir, "/tmp/muclogs"},
{access_log, muc}
]},
{mod_offline, [{access_max_user_messages, max_user_offline_messages}]},
{mod_privacy, []},
{mod_private, []},
% {mod_private, [{backend, mnesia}]},
% {mod_private, [{backend, odbc}]},
{mod_register, [
%%
%% Set the minimum informational entropy for passwords.
%%
%%{password_strength, 32},
%%
%% After successful registration, the user receives
%% a message with this subject and body.
%%
{welcome_message, {""}},
%%
%% When a user registers, send a notification to
%% these XMPP accounts.
%%
%{registration_watchers, ["admin#localhost"]},
%%
%% Only clients in the server machine can register accounts
%%
{ip_access, [
{allow, "0.0.0.0/0"}]},
%%
%% Local c2s or remote s2s users cannot register accounts
%%
%%{access_from, deny},
{access, register}
]},
{mod_roster, []},
{mod_sic, []},
{mod_vcard, [%{matches, 1},
%{search, true},
%{host, directory.#HOST#}
]},
UPDATE : Moved to ejabberd. Modules enabled in ejabberd :
%%% =======
%%% MODULES
%%
%% Modules enabled in all ejabberd virtual hosts.
%%
{modules,
[
{mod_adhoc, []},
{mod_announce, [{access, announce}]}, % requires mod_adhoc
{mod_caps, []},
{mod_configure,[]}, % requires mod_adhoc
{mod_admin_extra, []},
{mod_disco, []},
%%{mod_echo, [{host, "echo.localhost"}]},
{mod_irc, []},
%% NOTE that mod_http_fileserver must also be enabled in the
%% "request_handlers" clause of the "ejabberd_http" listener
%% configuration (see the "LISTENING PORTS" section above).
%%{mod_http_fileserver, [
%% {docroot, "/var/www"},
%% {accesslog, "/var/log/ejabberd/access.log"}
%% ]},
{mod_last, []},
{mod_muc, [
%%{host, "conference.#HOST#"},
{access, muc},
{access_create, muc},
{access_persistent, muc},
{access_admin, muc_admin},
{max_users, 500}
]},
%%{mod_muc_log,[]},
{mod_offline, [{access_max_user_messages, max_user_offline_messages}]},
{mod_privacy, []},
{mod_private, []},
{mod_proxy65, [
{access, local},
{shaper, c2s_shaper}
]},
{mod_pubsub, [ % requires mod_caps
{access_createnode, pubsub_createnode},
{pep_sendlast_offline, false},
{last_item_cache, false},
%%{plugins, ["default", "pep"]}
{plugins, ["flat", "hometree", "pep"]} % pep requires mod_caps
]},
{mod_register, [
%%
%% After successful registration, the user receives
%% a message with this subject and body.
%%
{welcome_message, {"Welcome!",
"Welcome to a Jabber service powered by Debian. "
"For information about Jabber visit "
"http://www.jabber.org"}},
%% Replace it with 'none' if you don't want to send such message:
%%{welcome_message, none},
%%
%% When a user registers, send a notification to
%% these Jabber accounts.
%%
%%{registration_watchers, ["admin1#example.org"]},
{access, register}
]},
{mod_roster, []},
%%{mod_service_log,[]},
%%{mod_shared_roster,[]},
{mod_stats, []},
{mod_time, []},
{mod_vcard, []},
{mod_version, []}
]}.
As mentioned in the link you reference, I think you have to use ejabberd to benefit from that API (and many more).
For creating rooms you need to use REST API, please see official documentation -https://mongooseim.readthedocs.io/en/2.0.0/REST-API. Also pay attention to the Swagger Doc at the end of this page
Related
If you want to load module sources and/or javadocs you write following sbt:
lazy val joda_timeV = "1.2.3"
lazy val scalatagsV = "1.2.3"
lazy val upickleV = "1.2.4"
lazy val autowireV = "1.2.5"
lazy val scalarxV = "1.2.6"
libraryDependencies ++= Seq(
"joda-time" % "joda-time" % joda_timeV withJavadoc(),
"com.lihaoyi" %%% "scalatags" % scalatagsV withSources() withJavadoc(),
"com.lihaoyi" %% "upickle" % upickleV withSources() withJavadoc(),
"com.lihaoyi" %%% "autowire" % autowireV withJavadoc(),
"com.lihaoyi" %%% "scalarx" % scalarxV withSources(),
"org.scalatestplus.play" %% "scalatestplus-play" % scalatestplus_playV % "test" withSources() withJavadoc()
),
In mill you say
override def ivyDeps = Agg(
ivy"joda-time:joda-time:${joda_timeV}",
ivy"com.lihaoyi:::scalatags:${scalatagsV}",
ivy"com.lihaoyi::upickle:${upickleV}",
ivy"com.lihaoyi:::autowire:${autowireV}",
ivy"com.lihaoyi:::scalarx:${scalarxV}"
)
but how can you add withJavadoc() or withSources() or withSources() withJavadoc() in to mill build.sc?
There is function .withConfiguration(String) but no scaladoc how to use it.
Is it possible to define that a module is available only in test (like org.scalatestplus.play in the previous code) or should I create separate ivyDeps for testing module?
Regarding your first question, I assume, your are interested in good IDE support, e.g. completion and jump-to the sources of your dependencies.
Mill already supports IDE integration. It comes with a project generator for IntelliJ IDEA (mill mill.scalalib.GenIdea/idea), which automatically downloads the sources for you. Alternatively, you can use the new BSP Support (Build Server Protocol) which should in combination with the Metals Language Server (https://scalameta.org/metals/) provide a nice editing experience in various IDEs and Editors. Unfortunately, at the time of this writing, Mills built-in BSP server isn't as robust as its IDEA generator, but there is even another alternative, the Bloop contrib module. All these methods should provide decent code navigation through dependencies and completion.
And to your second question:
Is it possible to define that a module is available only in test (like org.scalatestplus.play in the previous code) or should I create separate ivyDeps for testing module?
Test dependencies are declared it the test modules (which are technically regular modules too).
// build.sc
// ...
object yourplaymodule extends PlayModule {
override def ivyDeps = Agg(
ivy"joda-time:joda-time:${joda_timeV}",
ivy"com.lihaoyi:::scalatags:${scalatagsV}",
ivy"com.lihaoyi::upickle:${upickleV}",
ivy"com.lihaoyi:::autowire:${autowireV}",
ivy"com.lihaoyi:::scalarx:${scalarxV}"
)
// ...
object test extends PlayTests {
override def ivyDeps = Agg(
ivy"org.scalatestplus.play::scalatestplus-play:${scalatestplus_playV}"
)
}
}
Edit 2021-09-16: Added the answer to the first question.
I implemented a 4D Interpolation in matlab, where performance is really important. The interpolation method is a nearest neighbor interpolation based on a delaunay triangulation. As I am quite new to matlab coding, I want to ask, if I should use arrays or cells instead of tables, because of their poor performance. Also the general question, if you see anything, where I can speed up my code. I already saved the mat files in v6 so this is not an option. Below the text you see the code of the main program. After that the code for the 2D interpolation.
the tables I loaded in consist of 7 coloums filled with AeroDataId, X_C coordinate, CP (pressure derivative), Mach number, lift coefficient, ReynoldsNumber and Transition. One AeroDataId belongs to in the most cases 280 x_c coordinates with the different pressure coefficients.
Filtering all the data seems to be faster than using sql queries.
clc
close
clear
%% ReynoldsNumbers and Transitions known in the database
ReynoldsNumbers=[1e6;1.5e6;2.5e6;5e6;8e6;14e6;25e6;50e6;100e6];
Transition=[0;0.1;0.2;0.3;0.4;0.5;0.6;0.7;0.8;0.9];
%% parameters
Ma=0.85;
C_l=0.345;
Tl=0.15;
Re=55e6;
AirfoilId=0;
delta=0.015;
delta_ini=0.15;
%% try to find the neighbours of the parameters, which already exist in the database
tic
Re_u=ReynoldsNumbers(ReynoldsNumbers==Re);
Tl_u=Transition(Transition==Tl);
Tl_o=[];
Re_o=[];
if isempty(Re_u)
Re_u_index=nearestpoint(Re,ReynoldsNumbers,'previous');
Re_o_index=nearestpoint(Re,ReynoldsNumbers,'next');
Re_o=ReynoldsNumbers(Re_o_index);
Re_u=ReynoldsNumbers(Re_u_index);
if Re < 1e6
Re_u=1e6;
Re_o=1.5e6;
elseif Re > 100e6
Re_u=50e6;
Re_o=100e6;
end
end
if isempty(Tl_u)
Tl_u_index=nearestpoint(Tl,Transition,'previous');
Tl_o_index=nearestpoint(Tl,Transition,'next');
Tl_u=Transition(Tl_u_index);
Tl_o=Transition(Tl_o_index);
end
toc
%% load data based on the airfoilId size of new_upper_airfoil 25000000x7 table
if AirfoilId==0
load('new_upper_airfoil_all_0');
load('new_lower_airfoil_all_0');
elseif AirfoilId==1
load('new_upper_airfoil_all_1');
load('new_lower_airfoil_all_1');
elseif AirfoilId==2
load('new_upper_airfoil_all_2');
load('new_lower_airfoil_all_2');
end
%% no need to to make all the interpolation with the whole data, only a specific delta
new_upper_airfoil=new_upper_airfoil_all(new_upper_airfoil_all.Ma < (Ma+delta_ini) & new_upper_airfoil_all.Ma > (Ma-delta_ini) & new_upper_airfoil_all.CL_res < (C_l+delta_ini) & new_upper_airfoil_all.CL_res > (C_l-delta_ini),2:7);
new_lower_airfoil=new_lower_airfoil_all(new_lower_airfoil_all.Ma < (Ma+delta_ini) & new_lower_airfoil_all.Ma > (Ma-delta_ini) & new_lower_airfoil_all.CL_res < (C_l+delta_ini) & new_lower_airfoil_all.CL_res > (C_l-delta_ini),2:7);
%% filter data for the first 2D - Interpoaltion and execute it
new_upper_airfoil1=new_upper_airfoil(new_upper_airfoil.ReynoldsNumber==Re_u & new_upper_airfoil.Transition==Tl_u,1:4);
new_lower_airfoil1=new_lower_airfoil(new_lower_airfoil.ReynoldsNumber==Re_u & new_lower_airfoil.Transition==Tl_u,1:4);
DV1=delaunay_nearest(new_upper_airfoil1, new_lower_airfoil1, Ma, C_l, delta);
DV_1=table(DV1.X_C, DV1.CP, repmat(Re_u,280,1),repmat(Tl_u,280,1),'VariableNames',{'X_C','CP','Re','Tl'});
%% secound
if ~isempty(Tl_o)
new_upper_airfoil2=new_upper_airfoil(new_upper_airfoil.ReynoldsNumber==Re_u & new_upper_airfoil.Transition==Tl_o,1:4);
new_lower_airfoil2=new_lower_airfoil(new_lower_airfoil.ReynoldsNumber==Re_u & new_lower_airfoil.Transition==Tl_o,1:4);
DV2=delaunay_nearest(new_upper_airfoil2, new_lower_airfoil2, Ma, C_l, delta);
DV_2=table(DV2.X_C, DV2.CP, repmat(Re_u,280,1), repmat(Tl_o,280,1),'VariableNames',{'X_C','CP','Re','Tl'});
else
DV_2=[];
end
%% third
if ~isempty(Re_o)
new_upper_airfoil3=new_upper_airfoil(new_upper_airfoil.ReynoldsNumber==Re_o & new_upper_airfoil.Transition==Tl_u,1:4);
new_lower_airfoil3=new_lower_airfoil(new_lower_airfoil.ReynoldsNumber==Re_o & new_lower_airfoil.Transition==Tl_u,1:4);
DV3=delaunay_nearest(new_upper_airfoil3, new_lower_airfoil3, Ma, C_l, delta);
DV_3=table(DV3.X_C, DV3.CP, repmat(Re_o,280,1),repmat(Tl_u,280,1),'VariableNames',{'X_C','CP','Re','Tl'});
else
DV_3=[];
end
%% fourth
if ~isempty(Re_o) && ~isempty(Tl_o)
new_upper_airfoil4=new_upper_airfoil(new_upper_airfoil.ReynoldsNumber==Re_o & new_upper_airfoil.Transition==Tl_o,1:4);
new_lower_airfoil4=new_lower_airfoil(new_lower_airfoil.ReynoldsNumber==Re_o & new_lower_airfoil.Transition==Tl_o,1:4);
DV4=delaunay_nearest(new_upper_airfoil4, new_lower_airfoil4, Ma, C_l, delta);
DV_4=table(DV4.X_C, DV4.CP, repmat(Re_o,280,1),repmat(Tl_o,280,1),'VariableNames',{'X_C','CP','Re','Tl'});
else
DV_4=[];
end
%% Interpolation of the 4 2D Interpolations
DV_inter=[DV_1;DV_2;DV_3;DV_4];
if size(DV_inter,1)==280
DV=DV_1(:,1:2);
% figure
% hold on
% plot(DV.X_C,-DV.CP,'bl-');
% grid on;
% xlabel('X_C');
% ylabel('Cp');
%
else
%% interpolation with inverse distance weighted interpoaltion
load('x_c0');
DV=zeros(281,2);
for x_c=1:1:280
x_c_inter=x_c0(x_c);
Find=DV_inter(DV_inter.X_C==x_c_inter,:);
cp_inter=IDW(Find.Re, Find.Tl,Find.CP,Re,Tl,-2,'ng',2);
DV(x_c,:)=[x_c_inter,cp_inter];
end
DV(281,:)=DV(1,:);
figure
hold on
plot(DV(:,1),-DV(:,2),'r-');
grid on;
xlabel('X_C');
ylabel('Cp');
end
function DV = delaunay_nearest(new_upper_airfoil,new_lower_airfoil,Ma,C_l,delta)
Error=true;
load('x_c0');
while(Error)
%% build table for the pressure distribution
DV=array2table(zeros(280,2),'VariableNames',{'X_C','CP'});
%% another smaller delta for the interpolation (if too small the exception will be catched and the interpolation is restarted with a higher delta
new_upper_airfoil_loop=new_upper_airfoil(new_upper_airfoil.Ma < (Ma+delta) & new_upper_airfoil.Ma > (Ma-delta) & new_upper_airfoil.CL_res < (C_l+delta) & new_upper_airfoil.CL_res > (C_l-delta),:);
new_lower_airfoil_loop=new_lower_airfoil(new_lower_airfoil.Ma < (Ma+delta) & new_lower_airfoil.Ma > (Ma-delta) & new_lower_airfoil.CL_res < (C_l+delta) & new_lower_airfoil.CL_res > (C_l-delta),:);
%% try to build the delaunay triangulation
try
DT=delaunayTriangulation(new_upper_airfoil_loop.Ma,new_upper_airfoil_loop.CL_res);
% figure
% hold on;
% triplot(DT);
% plot(Ma,C_l,'ro');
%% find nearest neighbor
pointindex=dsearchn(DT.Points,[Ma,C_l]);
point=DT.Points(pointindex,:);
Error=0;
catch
delta=delta+0.005;
disp('Die Deltas wurden um 0.005 erhöht, da der Bereich der Daten zu klein war.');
continue;
end
%% search for the nearest neighbor
new_upper_airfoil_loop=new_upper_airfoil_loop(new_upper_airfoil_loop.Ma==point(1,1) & new_upper_airfoil_loop.CL_res==point(1,2),1:2);
new_lower_airfoil_loop=new_lower_airfoil_loop(new_lower_airfoil_loop.Ma==point(1,1) & new_lower_airfoil_loop.CL_res==point(1,2),1:2);
%% 2D Interpolation for all 280 points of the airfoil with the same x/c coordinates
for x_c=1:1:280
x_c_inter=x_c0(x_c);
%% upper_airfoil
if x_c < 146
FIND=new_upper_airfoil_loop(abs(new_upper_airfoil_loop.X_C-x_c_inter)<0.0005,:);
if(isempty(FIND))
leftNeighborIndex=nearestpoint(x_c_inter,new_upper_airfoil_loop.X_C,'previous');
if isnan(leftNeighborIndex)
leftNeighborIndex=1;
end
rightNeighborIndex=leftNeighborIndex+1;
if rightNeighborIndex > height(new_upper_airfoil_loop)
rightNeighborIndex=leftNeighborIndex-1;
end
average=interp1([new_upper_airfoil_loop.X_C(leftNeighborIndex,:),new_upper_airfoil_loop.X_C(rightNeighborIndex,:)], [new_upper_airfoil_loop.CP(leftNeighborIndex,:),new_upper_airfoil_loop.CP(rightNeighborIndex,:)], x_c_inter, 'linear','extrap');
FIND.X_C(1,:)=x_c_inter;
FIND.CP(1,:)=average;
DV(x_c,:)=FIND;
else
FIND.X_C(1,1)=x_c_inter;
DV(x_c,:)=FIND(1,:);
end
end
%% lower airfoil
if x_c > 145
FIND=new_lower_airfoil_loop(abs(new_lower_airfoil_loop.X_C-x_c_inter)<0.00008,:);
if(isempty(FIND))
leftNeighborIndex=nearestpoint(x_c_inter,new_lower_airfoil_loop.X_C,'previous');
if isnan(leftNeighborIndex)
leftNeighborIndex=height(new_lower_airfoil_loop);
end
rightNeighborIndex=leftNeighborIndex-1;
average=interp1([new_lower_airfoil_loop.X_C(leftNeighborIndex,:),new_lower_airfoil_loop.X_C(rightNeighborIndex,:)], [new_lower_airfoil_loop.CP(leftNeighborIndex,:),new_lower_airfoil_loop.CP(rightNeighborIndex,:)], x_c_inter, 'linear','extrap');
FIND.X_C(1,:)=x_c_inter;
FIND.CP(1,:)=average;
DV(x_c,:)=FIND;
else
FIND.X_C(1,1)=x_c_inter;
DV(x_c,:)=FIND(1,:);
end
end
end
end
end
There's already a similar question here, but it is using Maven, and I'm using sbt. Moreover none of the solutions there worked for me
I'm using Spark 2.4.0, Scala 2.11.12 and IntelliJ IDEA 2019.1
My build.sbt looks like:
libraryDependencies ++= Seq(
"com.groupon.sparklint" %% "sparklint-spark212" % "1.0.12" excludeAll ExclusionRule(organization = "org.apache.spark"),
"org.apache.spark" %% "spark-core" % "2.4.0",
"org.apache.spark" %% "spark-sql" % "2.4.0",
"org.apache.spark" %% "spark-streaming" % "2.4.0",
"org.apache.spark" %% "spark-streaming-kafka" % "1.6.2",
"com.datastax.spark" %% "spark-cassandra-connector" % "2.4.0",
"com.typesafe.slick" %% "slick" % "3.3.0",
"org.slf4j" % "slf4j-nop" % "1.6.4",
"com.typesafe.slick" %% "slick-hikaricp" % "3.3.0",
"com.typesafe.slick" %% "slick-extensions" % "3.0.0"
)
Edit all over:
I will be receiving a stream of data from Kafka, which will be sent to the Spark Streaming context using:
val rawWeatherStream = KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](ssc, kafkaParams, topics)
From this, I want to create a stream of RawWeatherData objects. A sample output from the stream would look like:
(null,725030:14732,2008,12,31,11,0.6,-6.7,1001.7,80,6.2,8,0.0,0.0)
Things look all good, except that I need to remove the first null value to create the stream of RawWeatherData objects as the constructor cannot accept the first null value, but can accept all other values from the stream.
Just for clarity sakes, here's what RawWeatherData looks like (I cannot edit this):
case class RawWeatherData(
wsid: String,
year: Int,
month: Int,
day: Int,
hour: Int,
temperature: Double,
dewpoint: Double,
pressure: Double,
windDirection: Int,
windSpeed: Double,
skyCondition: Int,
skyConditionText: String,
oneHourPrecip: Double,
sixHourPrecip: Double) extends WeatherModel
To achieve that purpose, I send my stream into a function, which returns me the desired stream of RawWeatherData objects:
def ingestStream(rawWeatherStream: InputDStream[(String, String)]): DStream[RawWeatherData] = {
rawWeatherStream.map(_._2.split(",")).map(RawWeatherData(_))
}
Now I am looking to insert this stream into a MySQL/DB2 database. From this RawWeatherData object (725030:14732,2008,12,31,11,0.6,-6.7,1001.7,80,6.2,8,0.0,0.0), the left highlighted bold part is the primary key, and the right bold part is the value that has to be reduced/aggregated.
So essentially I want my DStream to have key-value pairs of ([725030:14732,2008,12,31] , <summed up values for the key>)
So after ingestStream, I try to perform this:
parsedWeatherStream.map { weather =>
(weather.wsid, weather.year, weather.month, weather.day, weather.oneHourPrecip)
}.saveToCassandra(CassandraKeyspace, CassandraTableDailyPrecip)
After the end of map, I try to write .reduceByKey(), but when I try that, the error says Cannot resolve symbolreduceByKey`. I'm not sure why this is happening as the function is available in the spark documentation.
PS. Right now weather.oneHourPrecip is set to counter in cassandra, so cassandra will automatically aggregate the value for me. But this will not be possible in other databases like DB2, hence I wanted an apt replacement, like reduceByKey in spark. Is there any way to proceed with such a case?
Type of your stream is DStream[RawWeatherData] and reduceByKey is available only on streams of type DStream[(K,V)], which is a stream of tuples consisting of key and value.
What you wanted to do is probably to use mapValues instead of map:
val parsedWeatherStream: DStream[(String, RawWeatherData)] = rawWeatherStream
.mapValues(_.split(","))
.mapValues(RawWeatherData)
As you can see by type of parsedWeatherStream from the snippet above, if you'd use mapValues, you'd not discard your keys and you could use reduceByKey.
I am using playframework 2.4.x, and this libraries
"org.scalatest" %% "scalatest" % "2.2.1" % "test"
"org.scalatestplus" %% "play" % "1.4.0-M3" % "test"
I want to check if therea are some strings in a List I build on the test, this is the code
val userTeams = validateAndGet((teamsUserResponse.json \ "teams").asOpt[List[TeamUser]]).map( x => x.teamKey )
userTeams must contain ("team1", "team2")
But I am getting this error
List("team1", "team2") did not contain element (team1,team2)
If you write ("team1", "team2") then you're actualy creating a tuple of two strings which is from perspective of the ScalaTest matcher a single element.
Based on documentation you have to use allOf:
userTeams must contain allOf ("team1", "team2")
I get the following error message about too many input arguments in my fprintf function. But it seems to me that just the right amount of arguments were passed.
All this is in the context of a guide GUI I made (see picture at the end).
Error while evaluating uicontrol Callback
calibration button hit
20
200
10
10
2520
25197
2520
25197
'C0 2520 25197 10 10'
Error using serial/fprintf (line 115)
Too many input arguments.
Error in UserInterface>StaticCalibrationBtn_Callback (line 202)
fprintf(handles.s, 'C0 %s %s %s %s',StartStepsStr,EndStepsStr,Increment,Wait);
Here is the code
function StaticCalibrationBtn_Callback(hObject, eventdata, handles)
% hObject handle to StaticCalibrationBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('calibration button hit');
Start = str2double(get(handles.CalFromUserTxt, 'string')); % Fetches the user inputed start location in mm and converts to double
disp(Start);
End = str2double(get(handles.CalToUserTxt, 'string')); % same for End position
disp(End);
Increment = get(handles.CalUserIncrementTxt, 'string'); % fetches the increment user inputed data as a string
disp(Increment);
Wait = get(handles.CalUserSpeedTxt, 'string'); % fetches the wait inputed data as a string
disp(Wait);
StartSteps = round(Start/0.00793750000); % computes the starting step position,double division
disp(StartSteps);
handles.StartSteps = StartSteps; % creats a place for the start steps inside the handles structure, to be fetched by anythingelsest be saved with guidata(hObject,handles)
EndSteps = round(End/0.00793750000); % computes the end step position
disp(EndSteps);
handles.EndSteps = EndSteps; % stores the end steps to be accessed by anything else must be saved with guidata(hObject,handles)
StartStepsStr = num2str(StartSteps); % converts the StartSteps double into a string so it can be sent over serial as a string
disp(StartStepsStr);
EndStepsStr = num2str(EndSteps); % converts the EndSteps double into a string so it can be sent over serial as a string
disp(EndStepsStr);
OutputString = strcat('C0' , {' '} , StartStepsStr , {' '} , EndStepsStr , {' '} , Increment , {' '} , Wait);
disp(OutputString);
fprintf(handles.s, 'C0 %s %s %s %s',StartStepsStr,EndStepsStr,Increment,Wait);
and where handles.s comes from
function SerialBtn_Callback(hObject, eventdata, handles)
% hObject handle to SerialBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA
comPort = get(handles.COMportTxt,'String');
if(~exist('serialFlag','var'))
[handles.s, handles.serialFlag] = setupSerial(comPort);
end
guidata(hObject,handles);
end
And the setupserial funciton
function [ s, flag] = setupSerial(comPort)
%Initialize serial port communication between Arduino and Matlab
%Ensure that the arduino is also communicating with Matlab at this time.
%if setup is complete then the value of setup is returned as 1 else 0.
flag =1;
s = serial(comPort);
set(s,'DataBits',8);
set(s,'StopBits',1);
set(s,'BaudRate',9600);
set(s,'Parity','none');
fopen(s);
a='b';
while (a~='a')
a=fread(s,1,'uchar');
end
if (a=='a')
disp('serial read');
end
fprintf(s,'%c','a');
mbox = msgbox('Serial Communication setup.'); uiwait(mbox);
fscanf(s,'%u');
end
USING THE FOLLOWING RESOLVED THE ISSUE
OutputString = sprintf('C0 %s %s %s %s',StartStepsStr,EndStepsStr,Increment,Wait);
fprintf(handles.s,'%s', OutputString);
There are multiple functions called fprintf, one for files, one for serial objects and some others. You are using functionally which you know from the fprintf for files, but you are using it with a serial object. Check the right documentation which can be accessed via doc serial/fprintf