Problems in SD operations

arajakar
Posts: 13
Joined: Tue Sep 11, 2018 2:52 pm
Company: university oulu

Problems in SD operations

Post by arajakar » Tue Oct 09, 2018 5:18 pm

I was trying to run the SD 07 Example in waspmote v1.2. But I got an error result as below. Please tell me the reason for this.
E#
SD_07 example
mkdir failed
/data/log not created
===============================
Current ASCII Frame:
Length: 48
Frame Type: 128
frame (HEX): 3C3D3E80012333393437383736323523576173706D6F74655F50726F2330234143433A3233363B2D3335323B39323023
frame (STR): <=>€#394787625#Waspmote_Pro#0#ACC:236;-352;920#

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problems in SD operations

Post by libelium-dev » Wed Oct 10, 2018 9:13 am

Hi,

If the path and file is created, the code will return error because they exist but then the frames should be stored.

Regards

arajakar
Posts: 13
Joined: Tue Sep 11, 2018 2:52 pm
Company: university oulu

Re: Problems in SD operations

Post by arajakar » Wed Oct 10, 2018 10:49 am

how should I correct this?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problems in SD operations

Post by libelium-dev » Thu Oct 11, 2018 10:39 am

Hi,

Are there the path and file created yet? If so, it isn't a error, the behavior is as expected.

You can try to remove the file or format the SD card using the example codes.

Regards

arajakar
Posts: 13
Joined: Tue Sep 11, 2018 2:52 pm
Company: university oulu

Re: Problems in SD operations

Post by arajakar » Sun Oct 14, 2018 10:04 pm

Hi, Thank you for your information. I want to append attribute data to a text file in SD card. and I created the following code using example codes.
It seems this code runs upto reading attribute, but values doesn't append to the file. I'm a beginner for this and need your help.

#include <WaspBLE.h>
uint16_t flag = 0;
// define file name: MUST be 8.3 SHORT FILE NAME
char filename[]="FILE3.TXT";

// define variable
uint8_t sd_answer;

void setup()
{

// 0. Turn BLE module ON
BLE.ON(SOCKET0);

// 1. Make Waspmote visible to other BLE modules
BLE.setDiscoverableMode(BLE_GAP_GENERAL_DISCOVERABLE);

// 2. Make Waspmote connectable to any other BLE device
BLE.setConnectableMode(BLE_GAP_UNDIRECTED_CONNECTABLE);
USB.println(F("Waiting for incoming connections..."));

// open USB port
USB.ON();
USB.println(F("SD_3 example"));

// Set SD ON
SD.ON();

// Delete file
sd_answer = SD.del(filename);

if( sd_answer == 1 )
{
USB.println(F("file deleted"));
}
else
{
USB.println(F("file NOT deleted"));
}

// Create file
sd_answer = SD.create(filename);

if( sd_answer == 1 )
{
USB.println(F("file created"));
}
else
{
USB.println(F("file NOT created"));
}


}
void loop()
{
flag = BLE.readLocalAttribute(32);
USB.print(F("Attribute Value: "));
for(uint16_t i = 0; i < BLE.attributeValue[0]; i++)
{
USB.printHex(BLE.attributeValue[i+1]);
}
USB.println();
delay(2000);

//appends attribute values to file
sd_answer = SD.appendln(filename,BLE.attributeValue);

if( sd_answer == 1 )
{
USB.println(F("\n3 - append \"BLE.attributeValue\" in file adding an EOL"));
}
else
{
USB.println(F("\n3 - append error"));
}


}

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problems in SD operations

Post by libelium-dev » Mon Oct 15, 2018 10:25 am

Hi,

Try to implement something like this

Code: Select all

  flag = BLE.readLocalAttribute(32);
  USB.print(F("Attribute Value: "));
  for (uint16_t i = 0; i < BLE.attributeValue[0]; i++)
  {
    USB.printHex(BLE.attributeValue[i + 1]);
    SD.append(filename, (char*) BLE.attributeValue[i + 1]);
  }
Hope this help.
Regards

arajakar
Posts: 13
Joined: Tue Sep 11, 2018 2:52 pm
Company: university oulu

Re: Problems in SD operations

Post by arajakar » Mon Oct 15, 2018 2:14 pm

Thank you for your response. I tried using your code, but it writes following output in the text file. What can be the reason for this and how can I correct this. I am just sending ''ABC'' string over 0x0020 handler from raspberry pi and I want to print it into the text file.


arajakar
Posts: 13
Joined: Tue Sep 11, 2018 2:52 pm
Company: university oulu

Re: Problems in SD operations

Post by arajakar » Mon Oct 15, 2018 10:24 pm


libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problems in SD operations

Post by libelium-dev » Tue Oct 16, 2018 10:04 am

Hi,

What output do you get through the serial monitor?

We think that you have to convert attributeValue to string like it is done internally in printHex() function.

Regards

arajakar
Posts: 13
Joined: Tue Sep 11, 2018 2:52 pm
Company: university oulu

Re: Problems in SD operations

Post by arajakar » Tue Oct 16, 2018 12:09 pm

Serial Monitor gives ''Attribute value : ABC, but it doesn't print on the text file. That's the issue I'm having here

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest