Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

emence's Content

There have been 17 items by emence (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#34371 specific memory access to sd - ovverride SPI

Posted by emence on 29 August 2012 - 02:00 PM in Netduino Plus 2 (and Netduino Plus 1)

You would probably need to modify the firmware to achieve what you want as the file system (FAT) is initialised when the sd card is inserted (note the small micro switch on the socket) triggers an interrupt, which does quite a lot behind the scenes.


So that's how it works!

It may be easier for you to create a a shield which has some flash on it which you can use as you want then use that as a buffer to write to the SD card.


I used an ArduinoMega2560, with a dataflash chip over SPI. That worked really well. But addressing a Dataflash, also means that reading and writing only works in pages of 512 bytes. and that can get complicated and inefficient really easy, when you need to address one specific byte of an image..

Reading and writing single bytes is very easy thanks to the filestream... but it's too dam slow.


How would one tingle with the firmware? is there an example i could look at?



#34369 specific memory access to sd - ovverride SPI

Posted by emence on 29 August 2012 - 01:28 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello!

Is there a way to reconfigure the SPI pins for the onboard microSd?
I want to use the sd card as external flash storage without using a very slow filestrem.

I need to allocate memory on the sd and then write to it without creating a file.

can i use
SPI.Configuration x = new SPI.Configuration(....

and how can i access the PA21/PGMD9 Pin that is used for Chipselect?
or would it be easier to configure the register of the µC to setup the SPI?
Do i need to modify the firmware?

Thanks!



#33831 writting to sd card - losing serialdata!

Posted by emence on 17 August 2012 - 03:18 PM in Netduino Plus 2 (and Netduino Plus 1)

I would move the code that writes the file to the camera_DataReceived method too. Or at least call the writing of the file in that method. That way you'll keep code execution a bit more under control.


I will do that, and post any helpful results here. Maybe its of any use someday...



#33823 writting to sd card - losing serialdata!

Posted by emence on 17 August 2012 - 01:15 PM in Netduino Plus 2 (and Netduino Plus 1)

No you didn't

sorry. i meant, i did that now... it looks like this.

static void camera_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            int bytesReceived = serial.BytesToRead;
            if (isPicture && bytesReceived > 0)
            {
              //  incomingSerial = true;
                
                serial.Read(Buffer, 0, bytesReceived);
                System.Array.Copy(Buffer, 0, serialBuffer, bufferLength, bytesReceived);

               // serial.Read(serialBuffer, bufferLength, bytesReceived);
                bufferLength += bytesReceived;
                Debug.Print("" + bufferLength);
               // incomingSerial = false;
            }
            else
            {
                if (bytesReceived > 0)
                {
                    serial.Read(serialBuffer, 0, bytesReceived);
                    bufferLength += bytesReceived;
                }
            }
}

Your buffer doesn't sync right, that's the main issue I think.


how can i check?!!!
i tried waiting until the serialbuffer on the netduino 512byte is filled up and write to the SD card while it's filling up. but most of the time there were only ~32bytes in the buffer then it stopped.
only after reading the serial, the serialbuffer from the serial filled again up to about 32bytes.

like i said

I would need to Thread the SD-write process somehow, without interrupting the eventhandler from the serial...


You've been a great help so far helping me comprehend what's going on. Thanks a lot!



#33814 writting to sd card - losing serialdata!

Posted by emence on 17 August 2012 - 09:38 AM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for your time!

Is there a reason Program isn't declared Static, while all methods and properties inside are static?


No reason...

I think you want to append to the buffer, not overwrite it all the time.


Did that.
this allowed me to save a smaller picture of 19200 bytes directly to the netduino.
and write it to the SD, after the picture was fully transferred.

Since I can't allocate 76800 bytes for a 320x240 picture I would need to Thread the SD-write process somehow, without interrupting the eventhandler from the serial...

There are only 60KB RAM right? I'd need 76.8KB :P



#33692 writting to sd card - losing serialdata!

Posted by emence on 15 August 2012 - 03:46 PM in Netduino Plus 2 (and Netduino Plus 1)

Could you maybe post the full project? It's hard to help you out with only one method available to analyse, especially when using global variables.


Sure, I can. If you really have the time :D I'm glad to.

Attached Files




#33685 writting to sd card - losing serialdata!

Posted by emence on 15 August 2012 - 03:12 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi emence,

What speed are you using for your serial connection?

If you use software flow control, are you able to capture all the data?

Chris


I'm on 115200 kbps/baud.
unfortunately the camera doesn't support any flow control at all. As soon as i request an image the camera starts sending one whole frame.

Whats weird is, that the serial-buffer(512bytes on the netduino) doesn't even fill up.
I wait till the bytes in the serial-buffer are > 0 and then immediately write to the SD card. So i write about 40 bytes each time. when i check the serial-Buffer again there are another 20ish bytes to write.
Still, at the end i'm losing data. As soon as I don't write to the SD-Card, every byte will be received. :angry:


static void camera_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
bytesReceived = serial.BytesToRead;
                if(bytesReceived > 0){
                    serial.Read(serialBuffer, 0, bytesReceived);
                    image.Write(serialBuffer, 0, bytesReceived); //data loss Filestream
                    bufferLength += bytesReceived;
                    Debug.Print("written: " + bufferLength);    
                }
}

I tried lowering the baudrate. still the same problem.
Does the interrupt-Routine (Event Handler) of the serial, interrupt the filestream to the sd card? :blink:

I'm really stuck on this... :(



#33330 writting to sd card - losing serialdata!

Posted by emence on 09 August 2012 - 02:32 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi,

I see only snapshots of your code, I don't see where "fs" is set. Could it be that it gets destroyed by the garbage collector?


I can write without any problems to the sd card and there are no errors.
I just can't receive all the bytes from the serial, while trying to write them to the sd card.
In the time i write to the sd card, a new set of data would be received. but since i'm still writing to the sd card, the incoming serial data is dismissed.



#33328 writting to sd card - losing serialdata!

Posted by emence on 09 August 2012 - 02:05 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello!

I'm receiving serialdata via the eventHandler
static void camera_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            lock(serialBuffer){
                int bytesReceived = serial.BytesToRead;
                //Debug.Print("" + bytesReceived);
                if (bytesReceived > 0)
                {
                    serial.Read(serialBuffer, 0, bytesReceived);
                    bufferLength += bytesReceived;
                }
            }
        }

works fine until i try to write the incomming data to the sd card.

            while (watchdog.ElapsedMilliseconds <= timeout && bytesWritten < size60)
            {
              
                fs.Write(serialBuffer, 0, bufferLength); //write received bytes to sd
                bytesWritten += bufferLength;
                Debug.Print("written: " + bytesWritten);
                bufferLength = 0;
               
            }
            fs.Close();

I'm receiving a picture from a camera.
if i lose the line
fs.Write(serialBuffer, 0, bufferLength);
I receive all the bytes of the picture.
When i write the bytes from buffer to SD, i lose some bytes.
I guess the write routine takes to long, and therefore the incoming serial-data can't be written to the buffer.

How can i buffer the incoming data without any loss?

Thanks in advance!



#31874 Bitmap functions and image editing

Posted by emence on 11 July 2012 - 08:38 PM in Netduino Plus 2 (and Netduino Plus 1)

No ideas? anybody? at least an explanation? :(



#31740 Bitmap functions and image editing

Posted by emence on 08 July 2012 - 09:08 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for the link! I looked through the code. they are also using the Bitmap class to read the image. Seems like that is possible with the netduino GO. I actually don't want to display the image, just process it. :) I want to rotate and re-size my raw image and make a bitmap from it.



#31736 Bitmap functions and image editing

Posted by emence on 08 July 2012 - 08:36 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello! I saved an image onto the SD card via a camera. I would like to use the re-size and rotate functions from the Bitmap Class, instead of writing them myself doing it line for line... I understand it's not included in the microFramework because it also includes GUI functions that are useless on a netduino(right so far?) - Are there any substitutes for the Bitmap class? - Would it be more efficient and faster to write the code myself? - How can I create a Bitmap file out of my raw image... any ideas? Thanks in advance!



#31472 Can't deploy. before and after firmware update

Posted by emence on 02 July 2012 - 10:29 AM in Netduino Plus 2 (and Netduino Plus 1)

This helped:
Switch to Emulator

I still don't know what exactly the problem is. Every other Project deploys fine. But with this one I now have to switch to emulator first and then back to usb to successfully deploy... weird :huh:



#31292 Can't deploy. before and after firmware update

Posted by emence on 28 June 2012 - 11:01 AM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for the replies! It seems there is something wrong with my code. I can deploy all other Projects. maybe i use to much space and there is no message for that. :blink: I'll post my findings here when I find the broken code.... Thanks all!



#31252 Can't deploy. before and after firmware update

Posted by emence on 27 June 2012 - 02:31 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello there.

Yesterday everything worked properly. deployed a hundred times testing a camera communication, whatever..
Today I couldn't deploy anymore:

An error has occurred: please check your hardware.



After checking all options and successfully Pinging the Netduino via MFDeploy, I decided to update to the newest firmware 4.2RC5... couse why not.
used this guide:
http://wiki.netduino...ep-by-step.ashx

everything worked like charm.

BUT: I still can't deploy!

Deployment: via USB Device NetduinoPlus_NetduinoPlus
Target framework: .Net Micro Framework 4.2
error: An error has occurred: please check your hardware.
And its properly listed in the device manager....

Any Ideas?

Thanks in Advance!



#30940 SerialPort as given parameter?

Posted by emence on 20 June 2012 - 10:40 AM in Netduino Plus 2 (and Netduino Plus 1)

Do you have by any chance another instance of "Ucamttl camera" declared above your Main method?


Yes. exactly! :rolleyes:

Of course I used a static Object! And declared a new one with the same name when calling the constructor!
Ahhh... such a simple mistake! Everything is working properly now! :lol:

Thanks for Your time!



#30899 SerialPort as given parameter?

Posted by emence on 19 June 2012 - 04:07 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi!

I'm trying to use SerialPort as a parameter for my other classes constructor:

serial1 = new SerialPort(SerialPorts.COM1, Constants.baud_cam, Parity.None, 8, StopBits.One);
serial1.DataReceived += new SerialDataReceivedEventHandler(camera_DataReceived);
serial1.Open();
Ucamttl camera = new Ucamttl(serial1);

Ucamttl class:
SerialPort serial;

    public Ucamttl(SerialPort sp)
    {
        serial = sp;
    }

I can't seem to use the serialPort in my Ucamttl class. It works well in the main routine though.
The error occurs when the ucamttl class tries to write to the serial ( serial.Write(_command,0,Constants.CMD_SIZE); )

    #### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (1) ####
    #### Message: 
    #### Thermocam.Program::SyncCam [IP: 0007] ####
    #### Thermocam.Program::Main [IP: 008d] ####

Since I'm a noob there are a lot of questions..
- In which class do i need to open the port?
- In which class do i need to implement the event handlers?
- and if, then how, and why?

Thanks for helping! :blink:




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.