I2C output error when sending an array - arrays

I have recently started using Node-RED in a Raspberry Pi and my quest is to connect to a couple of I2C devices with the use of the node-red-contrib-i2c package.
One action which I am trying to do is to send an array of integers to the I2C device with the I2C output node but I always get the error
TypeError: String.isString is not a function
I have tried a couple of different syntax but without success. I have included an export of the flow below.
[{"id":"d2a2b073.e222c","type":"function","z":"e442e95f.6c2b98","name":"","func":"msg.address = 96;\nmsg.command = 48;\nmsg.payload = [85,85];\nreturn msg;","outputs":1,"noerr":0,"x":316,"y":243,"wires":[["7061e7e7.ac6f98","65101109.cf323"]]},{"id":"ce6f4bff.3bf998","type":"inject","z":"e442e95f.6c2b98","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":126,"y":244,"wires":[["d2a2b073.e222c"]]},{"id":"7061e7e7.ac6f98","type":"debug","z":"e442e95f.6c2b98","name":"","active":true,"console":"false","complete":"true","x":539,"y":263,"wires":[]},{"id":"65101109.cf323","type":"i2c out","z":"e442e95f.6c2b98","name":"","i2cdevice":"3d751c57.1120f4","address":"96","command":"","payload":"","count":"2","x":567,"y":223,"wires":[]},{"id":"3d751c57.1120f4","type":"i2c-device","z":"","device":"/dev/i2c-1","address":"100"}]
An example of the msg.payload sent:
msg.address = 96;
msg.command = 48;
msg.payload = [85,85];
return msg;

Related

NodeRed modbus data to float

I am a beginner with Node-Red and I would like to read the data of a meter via modbus and then display it in float format
With Modbus-Read node I'm getting this data:
How can I to convert in a float number like 407.555
thanks in advance for the help
Update 06/11/2021: I'tryng to convert the array recived from modbus but the result is wrong.
I try tu use a function like this:
let pay = msg.payload;
const buf = Buffer.allocUnsafe(4);
buf.writeInt16BE(pay[0],2);
buf.writeInt16BE(pay[1],0);
msg.payload = buf.readFloatBE(0);
return msg;
In NodeRed if I add a debug I can read
0x1f85
0xb40
so is the same reading using a different modbus reader but the conversion in nodered with the function is 3.700156759202689e-32 and the value right is 2.18

Fingerprint module Command packets doesn't send response to smt32f4

Hı everyone
I am currently working on fingerprint module(fpm10).I read so many datasheet but every datasheet have different command packets I referenced R305 datasheet after that I wrote a Code for command packet to send STM32 but fpm10 doesnt send response to stm32.This is my verifypassword command packet Module send my receive my command packet but doesnt response.I debuged my cod and ı havent get any error
uint16_t FP_Verify_Password[16]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x07,0x13,0x00,0x00,0x00,0x00,0x00,0x05};
void Finger_Get_img(void)
{
delay_ms(500);
if(my_finger==true)
{
//only one time will be apply
for(i=6 ; i<=13 ; i++)
checksum+=FP_Verify_Password[i];
FP_Verify_Password[14]=checksum&0xFF00;
FP_Verify_Password[15]=checksum&0x00FF;
}
for(i=0;i<16;i++)
{
// USART_SendData(USART2,FP_Pack_Head[i]);
delay_ms(50);
USART_Finger(USART1,FP_Verify_Password[i]);
delay_ms(50);
USART_Finger(USART6,FP_Verify_Password[i]);
delay_ms(50);
}
delay_ms(2000);
// GPIO_ResetBits(GPIOG,GPIO_Pin_13);
my_finger=false;
}
Bluetooth and Finger print module config
//fingerprint module configurations
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
USART_InitStruct.USART_BaudRate=57600;
USART_InitStruct.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_InitStruct.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;
USART_InitStruct.USART_Parity=USART_Parity_No;
USART_InitStruct.USART_StopBits=USART_StopBits_1;
USART_InitStruct.USART_WordLength=USART_WordLength_8b;
USART_Init(USART1,&USART_InitStruct);
USART_Cmd(USART1,ENABLE);
USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);
//bluetooth module configurations
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource6,GPIO_AF_USART6);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource7,GPIO_AF_USART6);
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF;
GPIO_InitStruct.GPIO_OType=GPIO_OType_PP;
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStruct.GPIO_PuPd=GPIO_PuPd_UP;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_100MHz;
GPIO_Init(GPIOC,&GPIO_InitStruct);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6,ENABLE);
USART_InitStruct.USART_BaudRate=9600;
USART_InitStruct.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_InitStruct.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;
USART_InitStruct.USART_Parity=USART_Parity_No;
USART_InitStruct.USART_StopBits=USART_StopBits_1;
USART_InitStruct.USART_WordLength=USART_WordLength_8b;
USART_Init(USART6,&USART_InitStruct);
USART_Cmd(USART6,ENABLE);
This my command packet

Ethernet connect fails with LWIP in mbed os

I'm using an mbed enabled board for development, I need to run an Ethernet application on it.
I tried to create a connection by using the following code:
network = new EthernetInterface();
network->connect();
// Show the network address
const char *ip = network->get_ip_address();
printf("IP address is: %s\n", ip ? ip : "No IP");
Normally it should work, But it fails in the LWIPInteraface class's bringup API at osSemaphoreAcquire, returning a timeout error.
if (!netif_is_link_up(&netif)) {
if (blocking){
if (osSemaphoreAcquire(linked, 15000) != osOK){
if (ppp){
(void) ppp_lwip_disconnect(hw);
}
return NSAPI_ERROR_NO_CONNECTION;
}
}
}
Any reason why I might be getting a timeout from osSemaphoreAcquire?
I tried increasing the timeout too but in vain.
If someone could help me with it, would be appreciated.
Thanks in advance.

Issue with sending XDR serialized data fron C to Python

I am trying to serialize a structure in C using XDR and send the serialized data to python over a tcp socket.
I tried using xdrmem_create() to create an XDR stream , call appropriate pack functions and pass the character array to a socket, to achieve this but I get an EOF error on the python side when I try to deserialize the stream .
I was able to achieve this operation successfully between
C server and C client, also between
python server and python client.
I get an error only when I use it with C and Python.
C snippet
#include<rpc/rpc.h>
....
xdrmem_create(&xdrs, arr, MAXLENGTH, XDR_ENCODE);
if(!xdr_person(&xdrs,&pkt)){
printf("ERROR");
};
.....
send(new_fd, arr, MAXLENGTH, 0)
Python snippet
import xdrlib
.....
data = s.recv(4)
unpacker = xdrlib.Unpacker(data)
message_size = unpacker.unpack_uint()
data = s.recv(message_size)
unpacker.reset(data)
person={}
person["name"] = unpacker.unpack_string().decode()
person["age"] = unpacker.unpack_int()
person["flag"] = unpacker.unpack_bool()
person["errEnum"] = unpacker.unpack_enum()
I wonder if there is a mismatch between the way data is serialized in C and Python.

QMI SDK start data session

I am using QMI SDK to start data session for the Sierra Wireless card MC7354 and Telus Sim Card. For now I can detect the device and the sim card like getting device info and IMSI number; however, I got some trouble with starting the data session. I follow the instructions in QMI SDK Documents and do the following code:
//set the default profile
ULONG rc3 = SetDefaultProfile(0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
fprintf(stderr, "SetProfile - Return Code: %lu\n", rc3);
//start the session
ULONG technology = 1;
ULONG profile_idx = 1;
struct ssdatasession_params session;
session.action = 1;
session.pTechnology = &technology;
session.pProfileId3GPP = &profile_idx;
session.pProfileId3GPP2 = NULL;
session.ipfamily = 4;
ULONG rc4 = SLQSStartStopDataSession(&session);
fprintf(stderr, "Start Session - Return Code: %lu\n",rc4);
SetDefaultProfile is working fine because it returns me the success code, but for the SLQSStartStopDataSession method, it always gives me the return code "1026", which means
Requested operation would have no effect
Does anyone know where I make mistakes and how should I modify the code? What does this return code mean?
A "No Effect" error in WDS Start Network (the underlying command sent when you use SLQSStartStopDataSession()) actually means that the device is already connected. You likely have configured an automatic connection setup in the modem.

Resources