I was not able to find any examples by googling so I thought I might ask help from here.
I have a txt file of n lines. Each line contains a blueprint for arduino uno to execute needed thing, for example flash a light. In my sript I want to "load" this file to UNO and go through this file line by line executing the steps.
I only found examples for this kind of thing for SD card usage.
For example:
https://www.arduino.cc/en/Reference/FileRead
http://forum.arduino.cc/index.php?topic=95303.0
However, I don't have SD card nor can I get one at the moment. Is there a way to read this file directly from pc and save it as an array for UNO to use.
Depending on the operating system you use, you can "pipe" the file to serial port, reading it from the Arduino using Serial object. On Linux:
cat myfile > /dev/ttyUSB0
Replace USB0 if necessary.
EDIT:
For windows you might use type command. Not sure if extended COM ports (other than 1 and 2) will work.
type myfile > COM5
You can try a different approach, that is store the content of required txt file / just the values to the EEPROM of the arduino.
The size of text that can be stored is minimal.The size of EEPROM solely depends on the Arduino used for e.g Mega has 4KB of EEPROM(One of the biggest), UNO has 1KB.This can be extended too as far as I know.
You can look into eeprom examples here -
https://www.arduino.cc/en/Reference/EEPROM
Its very easy to understand, just looks fuzzy and hard in the beginning.
There are other methods like using a SD card as you mentioned since that is not an option EEPROM is next best bet
Hope it helps.
Related
I'm experimenting with Ghidra and decompiling code intended for the MSP430 FR4133 Launchpad. I'm not sure if it's supported but Ghidra appeared to support MSP430 devices.
For a simple test, I'm using the example code at this link for the MSP EXP430FR4133 Launchpad.
This link contains a simple source program in this directory
MSP-EXP430FR4133_Software_Examples_windows\Firmware\Source\OutOfBox_MSP430FR4133. It's a simple program with a stop watch and temperature sensor.
I decided to load the binary that's also there in the Binary folder.
Then I selected TI MSP430 16-bit and let Ghidra do the analysis. The problem is that the decompiler doesn't provide any functions. I'm wondering if I've selected the wrong architecture or option?
UPDATE 1
I'm posting two extra images which show two functions but there's nothing of any significance.
You are not decompiling a raw binary, but a text file.
If you look at the Readme, it indicates that this is a pre-built TI-TXT image.
Basically, it contains small chunks of data encoded in hexadecimal, prefixed with the load address. See the format definition here.
Ghidra supports similar formats (Intel HEX or Motorola S-Records), but not TI-TXT. I didn't find a tool to convert it to a supported format, but this could probably be done with a small script.
Problem Solved!!! See below for solution
I was about to post this question and decided to check the web one more time. This site https://www.freepascal.org/docs-html/prog/progsu40.html
has this statement: The {$I filename} or {$INCLUDE filename} directive tells the compiler to read further statements from the file filename. The statements read there will be inserted as if they occurred in the current file.
This is exactly what I want to do with Arduino. How do I do it?
My Skill Set:
Writing code since 1967. Yes, I survived Y2K, which was a real thing; so I'm not new to programming/debugging. Mainframes and PC's. Very solid COBOL and SAS skills. Good skills with Borland/Lazarus Object Pascal. Weak C/C++ skills.
Background:
I have two working Arduino programs that are used on a model railroad. Prog1 uses infrared sensors to light LEDs that indicate the position of a train in a tunnel. I built the IRSensor class to handle a single sensor. Prog2 uses push-buttons to set a route through several track switches. Each track switch is set via a servo. I extended the Servo class to TOServo, which encapsulate most of the commonality in each track switch.
Now I'm working on a different model railroad and need merge Prog1 and Prog2 into a single program. Building Prog3 via copy/paste from programs 1 & 2 has proved unwieldy.
Problem:
How do I tell the Arduino pre-processor/compiler to "insert filename here; do not compile, pre-compile, or otherwise process the filename unless it is wrapped around the file asking for the insertion"?
What I've tried:
I built Prog3 by separating the code for Prog2 into 3 sections -- Main program storage & code and 2 include statements (Storage definitions and executable code for TOServo). These include statements pull in code that define or access an array of TOServo. I've used several suffixes (.h/.ino and .h/.cpp and .c/.c), and they all generate 'not declared in this scope' errors.
Finally:
Thanks for your help.
SOLUTION
My .ino file had grown large & unwieldy. The 'solution' was to move a large segment of code and matching declarations to external .h/.cpp files, and to access those files via #include statements. The program would not compile (undefined variables); they were, in fact, defined but the compiler couldn't find them. After many attempts to fix or rearrange the code, finally two things dawned on me.
1)The Arduino pre-compiler changes (rearranges?) my code so that C++ and the Arduino CPU can work together. This means that the code I see is not always the code the compiler sees.
2)My .h/.cpp files define and manage an array of servo objects. I could convert those files into an object that I access from the main .ino file.
So I've solved my problem. Thanks to all those who have posted in many forums/sites, especially to Tarick Welling who stayed with me to the end.
I am working on a project that involves GNU Radio/GRC and am not very familiar with the software. I am trying to output data to a serial port in GNU Radio using a block, but have not found a way to do so.
I was wondering if there is a pre-defined block that I can use to put this information to a serial port (USB on a Raspberry Pi 3), or if I had to create my own block. And if I had to create my own block, what that code would look like.
I have been able to write the data to a file using the File Sink to make sure I was getting data, and was wondering if the fix is something as simple as changing the File sink to an serial port sink. See picture below:
http://imgur.com/a/BdaMZ
I also did some research and found a github repo that looks like what I need -- unfortunately, the repository that it links to is no longer there. It did mention using pyserial, which is what I believe is meant for creating my own block in python. The link to this repo is below:
https://github.com/jmalsbury/gr-pyserial
… was wondering if the fix is something as simple as changing the File sink to an serial port sink.
Yes! Or No, it's even easier:
So, in fact, you could even simply use your file sink to write to e.g. /dev/ttyS0 (or /dev/ttyUSB0, or whatever is the device name of your serial port), but you'd have to set up the serial port to work like you want it to separately first. A way of doing that would be using stty, e.g.
stty -F /dev/ttyS0 115200
prior to running your flow graph.
Note that practically all in your flow graph point points to you not being sufficiently proficient with GNU Radio to successfully exchange data. I can't cover everything here, please read the official Guided Tutorials, but:
In a flow graph like yours, where the IO is the inherently rate-limiting element, you must not use "Throttle". Throttle is really just a tool to avoid a flowgraph consuming all your CPU (and to slow down simulations)
Giving your files a .grc ending is bad practice, as that is the ending reserved for GNU Radio flow graphs.
Giving it a .txt ending is plain misleading, since there's no text involved whatsoever. The "file format" (I wouldn't even call it a format) is really just plain binary numbers, as your computer handles them; not decimal ASCII representations of these floating point binary numbers
I also did some research and found a github repo that looks like what I need -- unfortunately, the repository that it links to is no longer there. It did mention using pyserial, which is what I believe is meant for creating my own block in python. The link to this repo is below:
Don't know what you're referring to, https://github.com/jmalsbury/gr-pyserial is perfectly existing!
I am trying to write and read from the EEPROM (25LC256) with my dsPIC 33FJ128MC804, I tried to use the examples from the website, however they used the explorer16 with the dsPIC 33FJ256MC710, so I take the code and I made the changes to used it in my dsPIC but I started to use interruptions, right now I can send data, but I am not able to read from the memory, even if I follow the steps in the datasheet of the EEPROM and using the configuration of the SPI.
Could you help me please with this little problem please?
UPDATE: I just noticed that whenever I send the code for read the STATUS register I always get zero as answer, is it normal?
source code: https://www.dropbox.com/s/wdahlmhjrilcqw6/main.c?dl=0
Can someone please explain to me the basic flow of how this is done.
So currently I a USB pic programmer and also a multi pic adapter. I understand that I can use this to write my program to the PIC. But Im not sure what happens before that, like how do I actually test it with LED or some input sensor etc that gives out analog data?
This is what I have now: http://www.piccircuit.com/shop/pic-programmer/26-ica01-usb-pic-programmer-set.html
So I need to connect this to to a breadboard? And if so how? Im completely lost!! This is the first time that I attempt to do this. What I have done is use my Synapse RF Engine EK2100 to build what I want.
Now what...?
I'm not entirely sure what you're trying to accomplish but what you purchased is a programmer for PIC microcontrollers. After you have written some code whether in assembly or C and compiled it to a hex file, this device will put that code onto a PIC microcontroller that you buy separately. Have you purchased a PIC device to program or do you just have the programmer and the EK2100 kit? If you provide some more detail we can point you in the right direction.
Write a basic 'flash LED' program and then wire-up the PIC to see if it works.
Hot tip - use the internal oscillator to minimise the external component count (makes things simpler). Browse around a PIC savvy site like http://digital-diy.com/ to get lots of interesting ideas and code samples.
The community there mostly use PIC Basic type languages (such as Swordfish) that will land you code that looks something like this (header/setup removed for ease of explanation):
While True
High(LED)
DelaymS(500)
Low(LED)
DelaymS(500)
Wend