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

Add ATTiny85 support (#1382) #1508

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

dfleck
Copy link

@dfleck dfleck commented Sep 11, 2021

Add ATTiny85 support (#1382)

Fix MY_DISABLED_SERIAL on AVR (#1505)
Add support to hwCPUFrequency
Add support to hwCPUTemperature

Add support to hwCPUFrequency
Add support to hwCPUTemperature
Different temperature offset
@dfleck
Copy link
Author

dfleck commented Sep 12, 2021

Butler never emailed the patch file to fix the coding style errors like he said he would. Probably due to the following:

Slack Send Pipeline step running, values are - baseUrl: , teamDomain: mysensorscore, channel: #jenkins, color: danger, botUser: false, tokenCredentialId: slack_token, notifyCommitters: false, iconEmoji: , username: , timestamp:
[Pipeline] emailext
An attempt to send an e-mail to empty list of recipients, ignored.

@chey
Copy link

chey commented Oct 29, 2021

CI seems to be broke?

@chey
Copy link

chey commented Oct 29, 2021

@dfleck I tested this patch against the latest 2.3.2 and there is a problem ... if you could take a look at it.

MySensors $ jq '.version' library.json
"2.3.2"
MySensors $ curl -s https://patch-diff.githubusercontent.com/raw/mysensors/MySensors/pull/1508.patch | patch -p 1
patching file hal/architecture/AVR/MyMainAVR.cpp
patching file hal/architecture/AVR/MyHwAVR.cpp
Hunk #2 FAILED at 323.
1 out of 2 hunks FAILED -- saving rejects to file hal/architecture/AVR/MyHwAVR.cpp.rej
patching file hal/architecture/AVR/MyHwAVR.h

@chey
Copy link

chey commented Oct 29, 2021

I just realized you are using the dev branch. I'll try that out.

@chey
Copy link

chey commented Oct 29, 2021

I tested this on the dev branch. The diff applies just fine. But I am getting errors in a generic sketch with hwCPUFrequency()

Sketch:

// Enable debug prints to serial monitor
//#define MY_DEBUG

// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95

#define MY_RF24_CE_PIN NOT_A_PIN
#define MY_RF24_CS_PIN 4

#define MY_SPLASH_SCREEN_DISABLED
#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE
#define MY_DISABLED_SERIAL

#define MY_NODE_ID 20
#define MY_PASSIVE_NODE
#define MY_DISABLE_REMOTE_RESET

#include <MySensors.h>

void setup()
{
}

void presentation()
{
}

void loop()
{
}

Errors:

Arduino/libraries/MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'uint16_t hwCPUFrequency()':
Arduino/libraries/MySensors/hal/architecture/AVR/MyHwAVR.cpp:327:29: error: 'TCCR1B' was not declared in this scope
  const uint8_t TCCR1Bsave = TCCR1B;
                             ^~~~~~
Arduino/libraries/MySensors/hal/architecture/AVR/MyHwAVR.cpp:327:29: note: suggested alternative: 'TCCR0B'
  const uint8_t TCCR1Bsave = TCCR1B;
                             ^~~~~~
                             TCCR0B
Arduino/libraries/MySensors/hal/architecture/AVR/MyHwAVR.cpp:328:29: error: 'TCCR1C' was not declared in this scope
  const uint8_t TCCR1Csave = TCCR1C;
                             ^~~~~~
Arduino/libraries/MySensors/hal/architecture/AVR/MyHwAVR.cpp:328:29: note: suggested alternative: 'TCCR1A'
  const uint8_t TCCR1Csave = TCCR1C;
                             ^~~~~~
                             TCCR1A
exit status 1
Error compiling for board ATtiny45/85 (Optiboot).

I'm using https://github.com/SpenceKonde/ATTinyCore if that makes a difference.

Fix sense on a couple of if defs
@dfleck
Copy link
Author

dfleck commented Oct 29, 2021

Sorry. I messed up. It is fixed now and tested with a few different processors now.

@chey
Copy link

chey commented Oct 30, 2021

I'm able to apply the patch now.

Here is the sketch I'm testing with:

#define MY_RADIO_RF24

#define MY_RF24_CE_PIN NOT_A_PIN
#define MY_RF24_CS_PIN 4

#define MY_SPLASH_SCREEN_DISABLED
#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE
#define MY_DISABLED_SERIAL

#define MY_NODE_ID 29
#define MY_PASSIVE_NODE
#define MY_DISABLE_REMOTE_RESET

#include <MySensors.h>

#define OPEN 1
#define CLOSE 0
#define CHILD_ID 1

MyMessage msg(CHILD_ID, V_TRIPPED);

uint8_t value = OPEN;

void presentation()
{
  sendSketchInfo("FakeDoorTest", "1.0");
  present(CHILD_ID, S_DOOR);
}

void loop()
{
  value = value == OPEN ? CLOSE : OPEN;
  send(msg.set(value));
  sleep(10000);
}

Here is the output on the gateway if anyone would like to review it:

Oct 29 22:14:30 DEBUG TSF:MSG:READ,29-29-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
Oct 29 22:14:30 DEBUG SGN:PRE:SGN NREQ,FROM=29
Oct 29 22:14:30 DEBUG SGN:PRE:WHI NREQ,FROM=29
Oct 29 22:14:30 DEBUG SGN:PRE:SGN NREQ,TO=29
Oct 29 22:14:30 DEBUG SGN:PRE:WHI NREQ,TO=29
Oct 29 22:14:30 DEBUG SGN:SGN:NREQ=29
Oct 29 22:14:30 DEBUG !TSF:MSG:SEND,0-0-29-29,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=NACK:0100
Oct 29 22:14:30 DEBUG !SGN:PRE:XMT,TO=29 FAIL
Oct 29 22:14:32 DEBUG TSF:MSG:READ,29-29-0,s=255,c=0,t=17,pt=0,l=11,sg=0:2.4.0-alpha
Oct 29 22:14:32 DEBUG TSF:MSG:READ,29-29-0,s=255,c=3,t=6,pt=1,l=1,sg=0:255
Oct 29 22:14:39 DEBUG TSF:MSG:READ,29-29-0,s=255,c=3,t=11,pt=0,l=12,sg=0:FakeDoorTest
Oct 29 22:14:39 DEBUG TSF:MSG:READ,29-29-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
Oct 29 22:14:39 DEBUG SGN:PRE:SGN NREQ,FROM=29
Oct 29 22:14:39 DEBUG SGN:PRE:WHI NREQ,FROM=29
Oct 29 22:14:39 DEBUG SGN:PRE:SGN NREQ,TO=29
Oct 29 22:14:39 DEBUG SGN:PRE:WHI NREQ,TO=29
Oct 29 22:14:39 DEBUG SGN:SGN:NREQ=29
Oct 29 22:14:39 DEBUG TSF:MSG:SEND,0-0-29-29,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
Oct 29 22:14:39 DEBUG SGN:PRE:XMT,TO=29
Oct 29 22:14:39 DEBUG TSF:MSG:READ,29-29-0,s=255,c=0,t=17,pt=0,l=11,sg=0:2.4.0-alpha
Oct 29 22:14:39 DEBUG TSF:MSG:READ,29-29-0,s=255,c=3,t=6,pt=1,l=1,sg=0:255
Oct 29 22:15:10 DEBUG TSF:MSG:READ,29-29-0,s=1,c=1,t=16,pt=1,l=1,sg=0:0
Oct 29 22:15:10 DEBUG TSF:MSG:READ,29-29-0,s=1,c=1,t=16,pt=1,l=1,sg=0:1
Oct 29 22:15:20 DEBUG TSF:MSG:READ,29-29-0,s=1,c=1,t=16,pt=1,l=1,sg=0:0
Oct 29 22:15:30 DEBUG TSF:MSG:READ,29-29-0,s=1,c=1,t=16,pt=1,l=1,sg=0:1

Another smaller issue though, I'm getting the following error unless I'm using #define MY_DISABLED_SERIAL

Arduino/libraries/MySensors/hal/architecture/AVR/MyMainAVR.cpp: In function 'int main()':
Arduino/libraries/MySensors/hal/architecture/AVR/MyMainAVR.cpp:35:7: error: 'serialEventRun' was not declared in this scope
   if (serialEventRun) {
       ^~~~~~~~~~~~~~
exit status 1
Error compiling for board ATtiny45/85 (Optiboot).

@dfleck
Copy link
Author

dfleck commented Oct 30, 2021

The ATTiny85 doesn't have a "real" serial port, just a shift register. So the chip libraries don't have a serialEventRun() function. I've seen some sketches include a line to weak link serialEventRun() but I chose to force a MY_DISABLED_SERIAL so the developer has a reminder they need to use software serial or some such workaround. Besides, after you add a radio there isn't much in the way of leftover pins for serial plus whatever your monitoring :-).

The presentation message failing the first time it is sent is a bit beyond my understanding of MySensors.

I would apply Butler's script but I never receive them.

@chey
Copy link

chey commented Oct 30, 2021

I'm thinking the FAILs there are because I'm using a gateway on v2.3.2 and my testing device was on dev (with these patches).

Not 100% though. Just a thought.

I'm not really sure how compatible the two versions are supposed to be.

@dfleck
Copy link
Author

dfleck commented Oct 31, 2021

I don't have a good way to diagnose this (I end up taking down my home automation MySensor interface to look at the gateway). I run different versions from the gateway because I don't want to reflash all of my devices every upgrade and it seems to work, but I wouldn't know if there was a temporary failure. I have no clue how compatible different versions are supposed to be. On top of that my ATTiny85 development board has stopped working. Ugh!
A couple of ideas. Does the exact same code work properly on an Uno? Could it be related to #define MY_RF24_CE_PIN NOT_A_PIN which is a different pull request?

@chey
Copy link

chey commented Oct 31, 2021

Could it be related to #define MY_RF24_CE_PIN NOT_A_PIN which is a different pull request?

I think you might be right. I don't think I applied #1381 along with your patch that time. I'll have to retry it.

@dfleck
Copy link
Author

dfleck commented Nov 1, 2021

All this request really does is "fix" serialEventRun(), implement HW frequency (which fixes a bunch of compile errors from different timer names), and implement HW temperature. I would be amazed if it had any impact on the wireless protocol.

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

Successfully merging this pull request may close these issues.

None yet

2 participants