Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux_C for WT931, s_ucWitDataBuff (from ucData) always not 0x55 [ubuntu 22.04] #6

Open
Maximus0079 opened this issue Mar 21, 2024 · 4 comments

Comments

@Maximus0079
Copy link

Maximus0079 commented Mar 21, 2024

Hi! Sorry for the disturbance, but it's been one week that I'm on that issue.

First, the source as cloned didn't assign p_WitSerialWriteFunc callback function at all.
Comparing to the NORMAL_C++ version, I added a static void SensorUartSend(uint8_t *ucData, uint32_t uiSize) function and used it with WitSerialWriteRegister(SensorUartSend); implemented it after WitInit().
This callback calls serial_write_data() from serial.c.

Even with this, AutoScanSensor() is never getting `s_cDataUpdate different of 0, because s_ucWitDataBuff is never 0x55.

I monitored the data at all points, and the integrity is kept all the way in writing data for WitReadReg(). But reading the data is frequently only over 249(0xF9), and only sometimes lower values under 0x7F, but never 0x55....

I also tweak with Delayms() and waiting shorter time in AutoScanSensor() thinking data is skipped, but no change. Also tried with longer waiting just to see but the same.

To make work the NORMAL_C++ WIN version, I had to change the last value of c_uiBaud[] to 921600 for the WT931 sensor, and all worked.
I made the same to Linux_C and even only 921600, but still no 0x55 in the readings.

And of course, I checked all the rules.d for serial opening, but never had error opening the port returning 3 at fd=open(dev, O_RDWR|O_NOCTTY)

Please, I hope it can be solved.

@WITMOTION
Copy link
Owner

WITMOTION commented Mar 22, 2024 via email

@Maximus0079
Copy link
Author

Maximus0079 commented Mar 22, 2024

Hi! Thank you for your quick answer.


Yes, I already used your software for the WT61P module, but I was passing through an Arduino. All went fine.


I use the source from here for the Linux version.
I compared it with the WIN version from here here.

The WIN version worked after adding 921600 in c_uiBaud[]

So implemented AutoScanSensor() and added 921600 rate to the Linux version.


But still no 0x55 found. Shouldn't be related to the fact that the serial port is read 1 by 1 length ?


Best regards

@WITMOTION
Copy link
Owner

WITMOTION commented Mar 24, 2024 via email

@Maximus0079
Copy link
Author

The problem is solved! I should have continued the baud rate modification to the serial.h file too. The serial_open() function didn't have had implemented the 921600 baud value. Should I pull the modifications? Even if no writing permissions ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants