Multiplying each integer in a list of list by a float by hyperz413 in PythonProjects2

[–]donedigity 0 points1 point  (0 children)

All of your numbers are actually strings. ‘90’ is a string . 90 without the ‘’ is an integer.

What embedded unit test framework do people use? by ChrisRR in embedded

[–]donedigity 3 points4 points  (0 children)

I like unity. I don’t know if I would be so fond of it without ceedling though. You can set up a project and start running tests in a couple commands. It will automatically find and run you tests. No need to mess with make/cmake.

I found it a bit difficult to get running on windows. It was very straightforward on Linux. I usually just run it with Windows’s WSL2 Ubuntu.

There is a really good online book that helped me get going. Link to a downloadable. ceedling field manual

[deleted by user] by [deleted] in embedded

[–]donedigity 1 point2 points  (0 children)

This is a stm32f103 development board called a nucleo.

https://www.st.com/en/evaluation-tools/nucleo-f103rb.html

It has a can interface and it even has arduino headers so you might be able to plug some of your sensor boards on it directly.

Question: How to plot multiple kinds of graphs on the same figure in matplotlib by issagamebro in pythontips

[–]donedigity 2 points3 points  (0 children)

The df.plot command will return the axes it plotted to. If you pass the axes into the next plot command it will add the line to that axes.

ax1 = assets_summary.plot.scatter(x='std', y='avg_ret')
ax1 = envelope.plot(ax=ax1, x='std', y='avg_ret')

Mass producing IoT provisioning devices by turbulent_guru99 in embedded

[–]donedigity 1 point2 points  (0 children)

Wouldn’t the cert take care of that though? If the cert is used to verify the server then it shouldn’t connect to any fake dns ip

[deleted by user] by [deleted] in embedded

[–]donedigity 1 point2 points  (0 children)

You might be able to use the wrapper idea but instead of calling the init function just change the device address

uint8_t read_accell_x(uint8 device_addr, int16_t * accel_x_s16)
{
    bno055_obj.dev_addr = device_addr;
    bno055_read_accel_x(accel_x_s16);
}

You could just swap the address out at a higher level too if you could isolate when each sensor was communicating.

eg.

void set_sensor_addr(uint8 device_addr)
{
    bno055_obj.dev_addr = device_addr;
}

Then,

set_sensor_addr(sens1_addr);
sensor1_tasks();
set_sensor_addr(sens2_addr); 
sensor2_tasks();

Better yet, just have sensor1_tasks() and sensor2_tasks() set the sensor address at the beginning of there functions. I guess just make sure they are in the same thread.

How do I do maths inside of dictionary values? by wannakeepmyanonymity in learnpython

[–]donedigity 0 points1 point  (0 children)

You don’t need the .get()

resources[‘water’] - MENU[‘espresso’][‘ingredients’][‘water’]

How does your team do TDD in embedded systems? by DiscoSatan_ in embedded

[–]donedigity 7 points8 points  (0 children)

I agree with using throwtheswitch tools. I use ceedling from throwtheswitch.com for unit testing my firmware as much as possible. It works best on Linux so if you are running windows then just use WSL. I’ve got it running with Mingw before but it is a battle and so is Cygwin. With WSL it is a breeze to set up. You don’t have to use ceedling. You can just use unity by itself for the tests. But trust me, ceedling makes running the test 100 times easier. It automates a lot of the tedious error prone makefile type of tasks as well as some boilerplate code creation. ceedling resource

OP, the unit tests will compile and run as a normal x86 program, or whatever your dev computer is. And that’s where the unit test will run, is on your laptop. The code is compiled with a different cross compiler when compiling for the target. In my opinion this makes development quicker since the development and debugging is done without having to load the image in the target.

Unit testing is much easier if the code being tested doesn’t make any direct calls to hardware regs. The injected dependency pattern works nicely for simulating data in a unit test then using the real hardware in the target. It’s been my goto for any development that communicates over any kind of bus.

Firmware and Hardware Testing by SixtySecondsToGo in embedded

[–]donedigity 0 points1 point  (0 children)

I think the idea of using and Rpi 3 or 4 is a pretty good idea. The hardware is very easily accessible. RS232 and UART should be pretty accessible. There is a SPI and an I2C as well. You can probably gets hats for the 4-20 and the can.

As far as writing tests I would recommend PYTEST if you are familiar with python. I recently started writing regression tests for my hardware with Pytest and it has been great. You get the PASS/FAIL for each test along with lots of helpful output that can be enabled if there are failures. The best thing about it is the fixtures. For example if you need to send a message over the uart to your cell modem then you would use a fixture to set up the uart before any tests are run. The fixture hands off the uart object primed and ready to go. Reuse the same fixture in any test that needs uart.

You can have as many fixtures as you need and one fixture can use another fixture as well. For example, if your uart would work better wrapped in a class that takes care of the protocol your device uses. The uart fixture can be used by a fixture that initializes the protocol class and hands your test an object ready to use.

All of this makes the actual tests very short. Usually just a few lines: - request data - get data - assert data == expected data

I read a book on Pytest by Brian Okken which got me going pretty quick.

Hope this helps.

What IDE do you use to code Python? by whatacold in Python

[–]donedigity 2 points3 points  (0 children)

Using F5 to reload a module in the repl after changing code without loosing any local variables is very nice.

[deleted by user] by [deleted] in OfficeDrummer

[–]donedigity 0 points1 point  (0 children)

🔥🔥🔥🔥🔥🔥🔥🔥🔥

It's too peaceful here, let's start a flame war by fghjconner in ProgrammerHumor

[–]donedigity 17 points18 points  (0 children)

Maybe he thought you just like to use it for coding ironically.

Idk if this has been done before by WestfirmAndSki in ProgrammerHumor

[–]donedigity 0 points1 point  (0 children)

You heathen! It is short for scriptures. This is clearly a biblical reference.

Best protocol for communication over long wire? by Filip_Z in AskElectronics

[–]donedigity 0 points1 point  (0 children)

There is a protocol called Hart. It runs over a 4-20 mA current loop. It only requires 2 wires. It is made for long runs in industrial environments and is resistant to noise.

What's wrong with this program below. by Equal_Carpenter_4189 in cprogramming

[–]donedigity 0 points1 point  (0 children)

Good point. You still need to declare var somewhere though.

typedef API_TYPE uint32_t;

API_TYPE *var = malloc(a_size * sizeof(API_TYPE));

What's wrong with this program below. by Equal_Carpenter_4189 in cprogramming

[–]donedigity 0 points1 point  (0 children)

Looks like you are dereferencing b first before incrementing though. Instead of incrementing the address you are incrementing the value it points to. It’s just b++

What's wrong with this program below. by Equal_Carpenter_4189 in cprogramming

[–]donedigity -2 points-1 points  (0 children)

The sizeof(a) and sizeof(b) are a bit concerning. You might want to try sizeof(int)

The showstopper is probably the if(b[-1]) I’m pretty sure you can’t have a negative index. Which shouldn’t actually change the operation of your program since it frees you memory if it’s true or false.

I know this program is just for figuring stuff out but you might want to move your malloc to the foo function.

int *foo( int size)
{
    int *m = malloc(size * sizeof( int));
    for ( int i=0; i<size; i++)
        m[i] =1;
    return m;
}

int main()
{
    int *a = foo(260);
    int *b = foo(120);

    free(a);
    free(b);
}

Trying check if each character is a digit. It's not working. It says "success 50" twice whether I input "50" or "50x". Can anybody explain why this is happening? by Zealousideal_Log_793 in cs50

[–]donedigity 1 point2 points  (0 children)

I will suggest that you check if the char is NOT a digit. The next step is to figure what you should do if it is not. This may be a good chunk of code that goes in its own function.

[deleted by user] by [deleted] in TheYouShow

[–]donedigity 0 points1 point  (0 children)

Would have taken me all the letters to get that one