problem in putting the file into the right folder by bluetoo

Discussions about CSEntry
Post Reply
Jing Liu
Posts: 42
Joined: July 1st, 2015, 3:19 am

problem in putting the file into the right folder by bluetoo

Post by Jing Liu »

Hi,

I am doing some testing on transferring files through bluetooth. But I found that i cannot control which folder I want to copy to on server device through client device.

According to the help, the following codes should work.

{Send RSI information file to another interviewer (on interviewer device) }
function SendRSIinfoIntv ( OthIntvCode, alpha(20) OthIntvName )
setfile( PNCfile, concat( strip(DirUtility), "SendRSIinfoIntv", ".pnc" ));
FileDelete( PNCfile );
FileWrite( PNCfile, "[SyncFile]" );
FileWrite( PNCfile, "Version=CSPro 6.1" );
FileWrite( PNCfile, "AppName=SendRSIinfoIntv" );
FileWrite( PNCfile, "Description=Send RSI information file to another interviewer" );
FileWrite( PNCfile, concat( "RootFolder=", strip(DirWrkprj) ));
FileWrite( PNCfile, concat( "DeviceName=", concat( edit("999",ThisDeviceCode), " (", strip(ThisIntvName), ")" ) ));
FileWrite( PNCfile, " " );
FileWrite( PNCfile, "[Connection]" );
FileWrite( PNCfile, "Type=Bluetooth" );
FileWrite( PNCfile, concat( "ServerDeviceName=", concat( edit("999", OthIntvCode), " (", strip(OthIntvName), ")" ) ));
FileWrite( PNCfile, " " );
FileWrite( PNCfile, "[Sync]" );
FileWrite( PNCfile, "ClientPath=/Ref/" );
FileWrite( PNCfile, concat( "Put=RSMinfo", edit("999",ThisDeviceCode), ".dat" ));
FileWrite( PNCfile, "ServerPath=/Ref/" );
close( PNCfile );
// Close the external dictionary file so that it can be read by the synchronization script
close( DEVICE );
close( SAMPLEHH );
close( RSIINFO );
close( TUNIS2015HH_DICT );
close( TUNIS2015RSI_DICT );
if sync( filename(PNCfile) ) = 1 then
errmsg( 006, strip(OthIntvName), OthIntvCode );
endif;
end;

{Receive reference files from interviewer (on interviewer device) }
function RecvRSIinfoIntv ()
setfile( PNCfile, concat( strip(DirUtility), "RecvRSIinfoIntv", ".pnc" ));
FileDelete( PNCfile );
FileWrite( PNCfile, "[SyncFile]" );
FileWrite( PNCfile, "Version=CSPro 6.1" );
FileWrite( PNCfile, "AppName=RecvRSIinfoIntv" );
FileWrite( PNCfile, "Description=Receive RSI information file from anther interviewer" );
FileWrite( PNCfile, concat( "RootFolder=", strip(DirWrkprj) ));
FileWrite( PNCfile, concat( "DeviceName=", concat( edit("999",ThisDeviceCode), " (", strip(ThisIntvName), ")" ) ));
FileWrite( PNCfile, " " );
FileWrite( PNCfile, "[Connection]" );
FileWrite( PNCfile, "Type=BluetoothServer" );
close( PNCfile );
if sync( filename(PNCfile) ) = 1 then
errmsg( 007 );
endif;
end;


But it does not, I can only copy the file to the folder defined by DirWrkprj.

While the following works, if I define the receiving folder on the server device part.

{Send RSI information file to another interviewer (on interviewer device) }
function SendRSIinfoIntv ( OthIntvCode, alpha(20) OthIntvName )
setfile( PNCfile, concat( strip(DirUtility), "SendRSIinfoIntv", ".pnc" ));
FileDelete( PNCfile );
FileWrite( PNCfile, "[SyncFile]" );
FileWrite( PNCfile, "Version=CSPro 6.1" );
FileWrite( PNCfile, "AppName=SendRSIinfoIntv" );
FileWrite( PNCfile, "Description=Send RSI information file to another interviewer" );
FileWrite( PNCfile, concat( "RootFolder=", strip(DirWrkprj) ));
FileWrite( PNCfile, concat( "DeviceName=", concat( edit("999",ThisDeviceCode), " (", strip(ThisIntvName), ")" ) ));
FileWrite( PNCfile, " " );
FileWrite( PNCfile, "[Connection]" );
FileWrite( PNCfile, "Type=Bluetooth" );
FileWrite( PNCfile, concat( "ServerDeviceName=", concat( edit("999", OthIntvCode), " (", strip(OthIntvName), ")" ) ));
FileWrite( PNCfile, " " );
FileWrite( PNCfile, "[Sync]" );
FileWrite( PNCfile, "ClientPath=/Ref/" );
FileWrite( PNCfile, concat( "Put=RSMinfo", edit("999",ThisDeviceCode), ".dat" ));
close( PNCfile );
// Close the external dictionary file so that it can be read by the synchronization script
close( DEVICE );
close( SAMPLEHH );
close( RSIINFO );
close( TUNIS2015HH_DICT );
close( TUNIS2015RSI_DICT );
if sync( filename(PNCfile) ) = 1 then
errmsg( 006, strip(OthIntvName), OthIntvCode );
endif;
end;

{Receive reference files from interviewer (on interviewer device) }
function RecvRSIinfoIntv ()
setfile( PNCfile, concat( strip(DirUtility), "RecvRSIinfoIntv", ".pnc" ));
FileDelete( PNCfile );
FileWrite( PNCfile, "[SyncFile]" );
FileWrite( PNCfile, "Version=CSPro 6.1" );
FileWrite( PNCfile, "AppName=RecvRSIinfoIntv" );
FileWrite( PNCfile, "Description=Receive RSI information file from anther interviewer" );
FileWrite( PNCfile, concat( "RootFolder=", strip(DirRef) ));
FileWrite( PNCfile, concat( "DeviceName=", concat( edit("999",ThisDeviceCode), " (", strip(ThisIntvName), ")" ) ));
FileWrite( PNCfile, " " );
FileWrite( PNCfile, "[Connection]" );
FileWrite( PNCfile, "Type=BluetoothServer" );
close( PNCfile );
if sync( filename(PNCfile) ) = 1 then
errmsg( 007 );
endif;
end;

The only different between the two is that the first one tryes to define the receiving folder on the client device part, while the second one tryes to define the receiving folder on the server device, part.

FYI,
DirWrkprj = "/storage/emulated/0/csentry/";
DirRef = concat( strip(DirWrkprj), "Ref/" );

Did i misundertood anything?

best

Jing
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: problem in putting the file into the right folder by blu

Post by josh »

That looks it should work. Can you post the synclog.txt from device that is sending the files?
Guest

Re: problem in putting the file into the right folder by blu

Post by Guest »

Hi,

It is strange that I cannot add an attachment.

2015-10-07 22:22:21,965 - -------------------------------------------------------------------------------
2015-10-07 22:22:21,966 - Starting sync SendRSIinfoIntv
2015-10-07 22:22:32,762 - ClientPath=/Ref/
2015-10-07 22:22:32,764 - Changing local directory to /storage/emulated/0/csentry/Ref
2015-10-07 22:22:32,765 - Changed to local directory /storage/emulated/0/csentry/Ref
2015-10-07 22:22:32,767 - Put=RSMinfo001.dat
2015-10-07 22:22:32,770 - Putting file RSMinfo001.dat
2015-10-07 22:22:32,938 - Completed sync SendRSIinfoIntv
2015-10-07 22:24:55,437 - -------------------------------------------------------------------------------
2015-10-07 22:24:55,438 - Starting sync SendRSIinfoIntv
2015-10-07 22:25:07,502 - ClientPath=/Ref/
2015-10-07 22:25:07,503 - Changing local directory to /storage/emulated/0/csentry/Ref
2015-10-07 22:25:07,504 - Changed to local directory /storage/emulated/0/csentry/Ref
2015-10-07 22:25:07,507 - Put=RSMinfo001.dat
2015-10-07 22:25:07,508 - Putting file RSMinfo001.dat
2015-10-07 22:25:07,622 - Completed sync SendRSIinfoIntv
2015-10-08 00:54:27,966 - -------------------------------------------------------------------------------
2015-10-08 00:54:27,975 - Starting sync SendRSIinfoIntv
2015-10-08 00:54:36,863 - ClientPath=/Ref/
2015-10-08 00:54:36,864 - Changing local directory to /storage/emulated/0/csentry/Ref
2015-10-08 00:54:36,865 - Changed to local directory /storage/emulated/0/csentry/Ref
2015-10-08 00:54:36,868 - Put=RSMinfo001.dat
2015-10-08 00:54:36,869 - Putting file RSMinfo001.dat
2015-10-08 00:54:36,940 - ServerPath=/Ref/
2015-10-08 00:54:36,940 - Changing to remote directory /Ref/
2015-10-08 00:54:36,977 - Completed sync SendRSIinfoIntv
2015-10-08 01:02:55,310 - -------------------------------------------------------------------------------
2015-10-08 01:02:55,312 - Starting sync SendRSIinfoIntv
2015-10-08 01:02:58,003 - ClientPath=/Ref/
2015-10-08 01:02:58,005 - Changing local directory to /storage/emulated/0/csentry/Ref
2015-10-08 01:02:58,005 - Changed to local directory /storage/emulated/0/csentry/Ref
2015-10-08 01:02:58,007 - Put=RSMinfo001.dat
2015-10-08 01:02:58,008 - Putting file RSMinfo001.dat
2015-10-08 01:02:58,092 - ServerPath=/Ref
2015-10-08 01:02:58,092 - Changing to remote directory /Ref
2015-10-08 01:02:58,133 - Completed sync SendRSIinfoIntv
2015-10-08 01:44:55,013 - -------------------------------------------------------------------------------
2015-10-08 01:44:55,016 - Starting sync GetRefSupv
2015-10-08 01:44:57,593 - ClientPath=/Ref/
2015-10-08 01:44:57,595 - Changing local directory to /storage/emulated/0/csentry/Ref
2015-10-08 01:44:57,597 - Changed to local directory /storage/emulated/0/csentry/Ref
2015-10-08 01:44:57,603 - Get=SAMPLEhh003.dat
2015-10-08 01:44:57,604 - Getting file SAMPLEhh003.dat
2015-10-08 01:44:57,690 - Get=DEVICE.dat
2015-10-08 01:44:57,691 - Getting file DEVICE.dat
2015-10-08 01:44:57,752 - Completed sync GetRefSupv



best

jing
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: problem in putting the file into the right folder by blu

Post by josh »

It seems like you were not logged when you made the last post (it came from Guest instead from Jing). That may be why you can't add the attachment.

It looks like you are doing the serverPath=/Ref/ command AFTER the Put command. Try moving the serverPath before the Put and see if that works.
Jing Liu
Posts: 42
Joined: July 1st, 2015, 3:19 am

Re: problem in putting the file into the right folder by blu

Post by Jing Liu »

Thanks Josh!

It works now!

best

Jing
jkajiba
Posts: 8
Joined: September 22nd, 2015, 1:40 pm

Re: problem in putting the file into the right folder by bluetoo

Post by jkajiba »

Dear Jing

I can see your code on filewrite is very strong.

kindly help on my code, I am failing to pass UID and DEVICE ID

Thank you

John

filewrite(pncFile,"CreatePath=/mccdata/'%'DeviceID'%'");
filewrite(pncFile,"CreatePath=/mccdata/'%'DeviceID%/'%'UID'%'");

filewrite(pncFile,"ClientPath=/mcc");
filewrite(pncFile,"ServerPath=/mccdata/'%'DeviceID'%'/'%'UID
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: problem in putting the file into the right folder by bluetoo

Post by Gregory Martin »

jkajiba: You should remove the ' characters around DeviceID and UID.
Post Reply