How to make sure user input value with RTOS working - c

hello i'm new with using RTOS with my board is NUCLEO-G474RE,with my question maybe not clear
well using C# making a GUI to Connect with my board i and sending a value while using RTOS method,
RTOS i have two task there ,Task1 is receive and sendback value that user type also led toggle,
Task2 also is UART receive then flash into my memory,with both task i have send back msg to tell
the task done,the problem is while i send value i cant accuracy flash my value into my board
i have type serval times,i forget to say i only open one uart so i dont think need semaphore
also the GUI i saw the value sendback is right but when i look at the stm32 memory side the value
is ASCII value when i send string is right but sending interger is wrong
fix my question with some pircture sorry i'm new here the picture only show the links
My goal is flash data with uart below is what happen
1.Here is two task ,Task 1 is write the uart receive data into my memory
enter image description here
here is my C# gui when i sending data i send back value
enter image description here
And while i looking at the memory but the data which write in is wrong
enter image description here

Related

I want to know when someone makes a phone call, what will the signal received from a phone look like?

I am learning to rewrite the code for the microcontroller integrated in the development Sim modules (such as Sim800C) to be able to control switching a device without having to use another MCU. If we can do that, we only need to add 1 transistor to be able to control a relay on and off.
I know at the output of the MCU (eg STM32F...) inside the sim module (eg sim800C) there will be a function to receive and read personal information stored in the sim card and decode the signal emitted from the Mobile base station: For example, when a call comes in, it will generate the sequence:
RING
+CLIP: "01203360211",161,"",0,"",0
....
So can anyone help me to know when the MCU outputs a string like the above, what will be its input 11110000,...? or something special in some form? I'm really confused. Thanks everyone!

How to send byte array to BLE device

Hi i need to write the following to my BLE device, it actually enable the device to send the data back or notify of the values. However after several attempts and changing the type of the data to be sent which is actually.
0xFD-0xFD-0xFA-0x05-0x0D-0x0A
i am not able to enable the device. Using the nRF application, i can write these directly which enable the device as well.
i know i need to use the byte array but i am not sure how should i add these to byte array. and when i add them directly to the
writeCharacteristic(characteristic);
it does not work at all.
The following code is the perfect and workable answer for the question posted. If any one is seeing it then please use the link below
How do I initialize a byte array in Java?

Get data form a sim card via a smart card reader

I' trying to get it using a SmartCard reader with the communication protocol PC/SC and CCID.
I send some bytes to the smartcard reader via the function sCardTransmit. The answer I get back is 61 2E. The documentation said that this means some data is available to read. But how can I read out the data with the functions from the library? Does this function will work SCardGetAttrib()? I thought I get the data back with the Transmit function.
Thanks for help,
Florian

Advice: trying to recognize when a device is not connected

I have some hard time trying to find a method to restart my state machine. In other words some part of what I ve got:
I have a module that when is powered up it stays for a debounce time of 0.5 s and then it goes in a state machine: first it send a string#anotherstring# then he start a timer of some period and when timer elapsed, it converts an analog signal/read a data (SPI,I2C) and sends that data followed by another #. The state machine goes back and start again the timer and send again the data ...
On another chip. I receive info from that module. So here is a state machine that complete the first string, second string, and then cumulates values in a buffer, again and again.
In some moment some external device ask for data, moment when the chip make some computation and sends it.
SO far so good. Every single part of this is working exept the part when the module is disconnected. Ok you may say no problem no data is send. Yes this is true, but what happens if the module is connected back. Until now to test my work I have reseted the chip disconect and connect the module. By doing this the chip is on the first state and the module goes from first state, everything is ok.
My qestion is how to determine when the device is disconected from the chip to restart the chip stat machine and to wait for the string#anotherstring# combination(first state).
Another question is how to determine if the communication is broken and not the power down. When putting back the comunication the data should be again send,preferably both modules to go from init state.
What I have in mind is to send some ack to the module from the chip. But I do not know exactly how. Basically I want this: when the module is disconected its state machine obviously start over and the chip state I want again to goes back to initial state.
if the comunication of the module is unplugged some how both statemachines to start over.
I do not know if I am clear with this. but please if there are questions ask. I will come with edits if I found something.
OTHER INFO: The module and the chip are some microcontrolers, the comunicaiton is UART.
Let me sketch a basic scheme you can use on the receiving side:
On your receiving side, you'll want to time-out if no valid/complete message is received within a reasonable time frame. This way, you'll detect when the module goes offline for whatever reason at any point in time.
The state machine that receives and processes the messages will also be reset in this case. This means you'll have a timer which, for example, is started when data is received and stopped when a message was correctly and fully received. If the timer times out, any message currently being received is declared invalid and discarded, and the receiver goes back to the start, looking for the next message.
Then, you'd have to implement in the receiver the code to detect when a message starts and/or ends. So if the module always starts by sending string#anotherstring# then the receiver will wait until it sees string# for example; anything else received is ignored by the receiver. Only after the expected prefix was detected the rest of the message receiving is done.
During the whole process, the receiver's messsage timeout timer is active and if any part of the message is not received in time the receiver assumes transmission problems and goes back to waiting for the start of the next message.

synchronisation issue within callback functions

In a continuous loop barcodes are scanned and if scan is valid text data and voice data are read out/played, which happens in differnt context. Text playback happens first, then its callback function gets executed, from there voice playback happens, and then its callback function. The issue is seen when multiple scanning is done, sometimes there is synchronisation issues. While text playback of 1st barcode is happening, if another scan is done, then voice data of 2nd barcode gets played(skipping text playback of 2nd). This behaviour is observed only sometimes, so it is kind of difficult to debug.
Any ideas how to provide synchronisation within callbacks?
Thanks in advance for any help.
-Aparna
Your question isn't very clear so lets assume you currently have 3 threads
Reads the barcode from hardware
Displays the code?
Audio playback of the code as text contained in the barcode
The thread reading the barcode is a producer of data and should push a work unit onto a consumer stack and should notify the stack that there is a work unit. Run a cursory google search for producer-consumer queue.
Threads 2 & 3 appear to be synchronous and should be combined into a single thread?

Resources