Can anyone work out why I can't get these two libraries to communicate to each other over LoRa?
https://github.com/sandeepmistry/arduino-LoRa
https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers/tree/master/SX1276
I can get each library to communicate with another device using the same lib and even compile the arduino code onto the stm32 and have an stm32 and arduino board talk fine but using one of each library they won't. As far as I can tell it can only be a LoRa settings difference.
Arduino Settings
#define TX_POWER 17 // valid range 2-17 on BOOST_PIN, 2-20 on PA_OUTPUT_RFO_PIN
#define TX_PA_PIN PA_OUTPUT_PA_BOOST_PIN
#define SPREADING_FACTOR 7 // 6 -> 12
#define SIGNAL_BANDWIDTH 250E3 // 125E3 //250E3 //62.5E3
#define LORA_FREQUENCY 915E6
#define SYNC_WORD 0x12
...
while (!LoRa.begin(LORA_FREQUENCY)) {
Serial.println(".");
delay(10);
}
// Configure the LoRa Radio
LoRa.setSpreadingFactor(SPREADING_FACTOR);
LoRa.setSignalBandwidth(SIGNAL_BANDWIDTH);
LoRa.setTxPower(TX_POWER, TX_PA_PIN);
LoRa.setSyncWord(SYNC_WORD);
LoRa.setCodingRate4(5);
LoRa.setPreambleLength(8);
LoRa.disableCrc();
LoRa.disableInvertIQ();
MBED Settings
#define frequency 915E6
#define bandwidth 1 //LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
#define datarate 7 // SPREADING FACTOR //LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips]
#define coderate 1 //LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define bandwidth_afc 0
#define preamble_len 8
#define symb_timeout 0
#define fix_len false
#define crc_on false
#define freq_hop_on false
#define hop_period 0
#define iq_inverted false
#define rx_continuous true
#define power 17
#define fdev 0
#define timeout 100000
...
lora.set_tx_config (modem_type::MODEM_LORA,
power,
fdev,
bandwidth,
datarate,
coderate,
preamble_len,
fix_len,
crc_on,
freq_hop_on,
hop_period,
iq_inverted,
timeout
);
lora.set_rx_config (modem_type::MODEM_LORA,
bandwidth,
datarate,
coderate,
bandwidth_afc,
preamble_len,
symb_timeout,
fix_len,
payload_len,
crc_on,
freq_hop_on,
hop_period,
iq_inverted,
rx_continuous
);
lora.init_radio(&lora_events);
lora.set_channel(frequency);
lora.set_public_network(false);
lora.receive();
Have tried setting both sync words to either 0x12 or 0x34 too.
Related
Eventually, I want to tap into the K-line of my Kawasaki Ninja with an (ISO 9141) OBD reader, using an ESP32 WROVER and a L9637 single-wire transceiver. To get there, I'm at the stage of confirming my L9637 chip is wired properly to my ESP32.
Here's where I am:
HardwareSerial Sender(1); // Serial port1 is the 'Sender'
HardwareSerial Receiver(2); // Serial port2 is the 'Receiver'
/*
* LilyGo TTGO T7 v1.5 pins
* ___________
* GND RST | | TXD GND
* N-C VP | ESP32 | RXD 27
* VN 26 | WROVER | 22 25 (22 <- SEND-Rx)
* 35 18 | TTGO | 21 32 (21 -> RCVR-Tx)
* 33 19 | T7 | 27 TDI (27 -> SEND-Tx)
* 34 23 | v1.5 | 25 4 (25 <- RCVR-Rx)
* TMS 5 | | GND 0
* N-C 3v3 | WiFi+BLE | 5v 2
* SD2 TCK | | TDO SD1
* CMD SD3 |______usb__| SD0 CLK
* (back) (+) (-) LiPo Batt Conn
*
* ____________
* 22 <- RX 1 | SENDER | 8 LI
* LO 2 | L9637 | 7 Vs(12v)
* (5v)Vcc 3 | tranceiver | 6 K ->-> K on #2
* 27 -> TX 4 |_____#1_____| 5 Gnd |
* |
* ____________ V
* 25 <- RX 1 | RECEIVER | 8 LI |
* LO 2 | L9637 | 7 Vs(12v) |
* (5v)Vcc 3 | tranceiver | 6 K <-<- K on #1
* 21 -> TX 4 |_____#2_____| 5 Gnd
*
* (need a 510ohm between K and Vs, and a cap to Gnd on each V)
*/
// define Rx and TX on the 2 L9637 chips with K's connected:
// TX is Input for K as output. RX is Output for K as input.
#define Sender_Txd_pin 27 // to Tx on Sender
#define Sender_Rxd_pin 22 // from Rx on Sender L9637
#define Receiver_Txd_pin 21 // to Tx on Receiver L9637
#define Receiver_Rxd_pin 25 // from Rx on Receiver
void setup() {
Serial.begin(115200);
// init both L9637 RX's with a short HIGH-LOW
Serial.println( "init both with Rx HIGH" );
pinMode( Sender_Rxd_pin, OUTPUT );
pinMode( Receiver_Rxd_pin, OUTPUT );
digitalWrite( Sender_Rxd_pin, HIGH );
digitalWrite( Receiver_Rxd_pin, HIGH );
delay(300);
Serial.println( "sending both Rx LOW" );
digitalWrite( Sender_Rxd_pin, LOW );
digitalWrite( Receiver_Rxd_pin, LOW );
delay(25);
Sender.begin(10400, SERIAL_8N1, Sender_Txd_pin, Sender_Rxd_pin); // iso9141 baud rate
Receiver.begin(10400, SERIAL_8N1, Receiver_Txd_pin, Receiver_Rxd_pin);
}
void loop() {
Sender.println( 3 ); // just an integer
delay( 200 );
while (Receiver.available()) {
char RxdChar = Receiver.read();
Serial.print(RxdChar);
}
delay(2000);
}
Note: I've tested the code and the ESP32 serial ports extensively. It works well. I've check the wiring on the (2) L9637 chips, properly powered, 510 ohm resistors, proper capacitors, with their K-lines connected to each other. When I Digital.Write to the Sender L9637 TX, I can see the K respond as well as the Receiver L9637 RX. But when I do the serial write, the Responder.available() never goes true. What gives?
I appreciate any assistance.
I'm trying to discover devices, from a coordinator, in my network.
So I sent an ND command to the coordinator and I'm correctly receiving response from other Xbee.
The next step will be to store the information I've received in a web application, in oder to send commands and data.
However, what I'm still missing is some parts in the frame respose. So far I've mapped the frame like this:
1 7E start frame
===== =================== MESSAGE LENGHT
2-3 0x00 0x19 -> 25
===== =================== PACKET TYPE
4 88 -> response to a remote AT command
5 02 frame ID
===== =================== AT COMMAND
6-7 0x4E 0x44 "ND"
8 00 status byte (00 -> OK)
===== =================== MY - Remote Address
9-10 0x17 0x85
===== =================== SH - SERIAL NUMBER HIGH
11-14 0x00 0x13 0xA2 0x00
===== =================== SL - SERIAL NUMBER LOW
15-18 0x40 0xB4 0x50 0x23
===== =================== SIGNAL
19 20
= ======== NI - Node Identifier
20 00
21 FF
22 FE
23 01
24 00
25 C1
26 05
27 10
28 1E
===== ===== CHECKSUM (25th bytes from MESSAGE LENGHT)
29 19
So, where I can find in this response the address of the device ?
My guess is in the NI part of the message but, I haven't find any example/information of how the data are organised.
Could someone point me in the right direction?
As someone told me in the dig.com forum
NI<CR> (Variable length)
PARENT_NETWORK ADDRESS (2 Bytes)<CR>
DEVICE_TYPE (1 Byte: 0=Coord, 1=Router, 2=End Device)
STATUS (1 Byte: Reserved)
PROFILE_ID (2 Bytes)
MANUFACTURER_ID (2 Bytes
So, loking to my frame response:
00 --- Node Identifier variable, (here 1 byte = 00 because no value is set up).
FFFE --- parent network address (2 bytes)
01 --- device type
00 --- status
C105 --- profile id
101E --- manufacturing id
This, afaik, means that in this last part of the frame, no information about address of the device are given. Only information are the SL and SH.
The 16-bit network address is what you've labeled "MY" (0x1785), and the 64-bit MAC address is the combination of SH/SL (00 13 A2 00 40 B4 50 23).
I am working on Beagle Bone Rev A5 and my UART1 and UART2 are working fine with these mux settings:
echo 20 > /sys/kernel/debug/omap_mux/uart1_rxd
echo 0 > /sys/kernel/debug/omap_mux/uart1_txd
echo 1 > /sys/kernel/debug/omap_mux/spi0_d0
echo 21 > /sys/kernel/debug/omap_mux/spi0_sclk
Now I want hardware flow control enabled and for that I want to use UART4 and UART5. Can anybody help me enabling Rx,Tx,RTS,CTS of UART 4 & 5? What will be the mux setting for these UARTs?
This page helped me a bit:
http://www.jerome-bernard.com/blog/2012/06/04/beaglebone-serial-ports-and-xbees/
You have to set :
UART4 - RX /sys/kernel/debug/omap_mux/gpmc_wait0 26 Mode 6 - Input
UART4 - TX /sys/kernel/debug/omap_mux/gpmc_wpn 6 Mode 6 - Output
UART5 - RX /sys/kernel/debug/omap_mux/lcd_data9 24 Mode 4 - Input
UART5 - TX /sys/kernel/debug/omap_mux/lcd_data8 4 Mode 4 - Output
I'm trying to figure out what is stored at a certain place on the stack with GDB. I have a statement:
cmpl $0x176,-0x10(%ebp)
In this function I'm comparing 0x176 to the -0x10(%ebp) and I am wondering if there is a way to see what is stored at -0x10(%ebp).
I am wondering if there is a way to see what is stored at -0x10(%ebp).
Assuming you have compiled with debug info, info locals will tell you about all the local variables in current frame. After that, print (char*)&a_local - (char*)$ebp will tell you the offset from start of a_local to %ebp, and you can usually find out what local is close to 0x176.
Also, if your locals have initializers, you can do info line NN to figure out which assembly instruction range corresponds to initialization of a given local, then disas ADDR0,ADDR1 to see the disassembly, and again understand which local is located at what offset.
Another alternative is to readelf -w a.out, and look for entries like this:
int foo(int x) { int a = x; int b = x + 1; return b - a; }
<1><25>: Abbrev Number: 2 (DW_TAG_subprogram)
<26> DW_AT_external : 1
<27> DW_AT_name : foo
<2b> DW_AT_decl_file : 1
<2c> DW_AT_decl_line : 1
<2d> DW_AT_prototyped : 1
<2e> DW_AT_type : <0x67>
<32> DW_AT_low_pc : 0x0
<36> DW_AT_high_pc : 0x23
<3a> DW_AT_frame_base : 0x0 (location list)
<3e> DW_AT_sibling : <0x67>
<2><42>: Abbrev Number: 3 (DW_TAG_formal_parameter)
<43> DW_AT_name : x
<45> DW_AT_decl_file : 1
<46> DW_AT_decl_line : 1
<47> DW_AT_type : <0x67>
<4b> DW_AT_location : 2 byte block: 91 0 (DW_OP_fbreg: 0)
<2><4e>: Abbrev Number: 4 (DW_TAG_variable)
<4f> DW_AT_name : a
<51> DW_AT_decl_file : 1
<52> DW_AT_decl_line : 1
<53> DW_AT_type : <0x67>
<57> DW_AT_location : 2 byte block: 91 74 (DW_OP_fbreg: -12)
<2><5a>: Abbrev Number: 4 (DW_TAG_variable)
<5b> DW_AT_name : b
<5d> DW_AT_decl_file : 1
<5e> DW_AT_decl_line : 1
<5f> DW_AT_type : <0x67>
<63> DW_AT_location : 2 byte block: 91 70 (DW_OP_fbreg: -16)
This tells you that x is stored at fbreg+0, a at fbreg-12, and b at fbreg-16. Now you just need to examine location list to figure out how to derive fbreg from %ebp. The list for above code looks like this:
Contents of the .debug_loc section:
Offset Begin End Expression
00000000 00000000 00000001 (DW_OP_breg4: 4)
00000000 00000001 00000003 (DW_OP_breg4: 8)
00000000 00000003 00000023 (DW_OP_breg5: 8)
00000000 <End of list>
So for most of the body, fbreg is %ebp+8, which means that a is at %ebp-4. Disassembly confirms:
00000000 <foo>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 10 sub $0x10,%esp
6: 8b 45 08 mov 0x8(%ebp),%eax # 'x' => %eax
9: 89 45 fc mov %eax,-0x4(%ebp) # '%eax' => 'a'
...
how can i calculate the subnet mask having ip address 128.2.19.4 and belong to the subnet 128.2.19.0/25.please give me the detail procedure.i want to learn to calculate.
Here's the algorithm with your example:
The subnet mask is just a representation of the "/25" part of your subnet address.
In IPv4, addresses are 32 bits long, the first 25 bits of which are ones:
1111 1111 1111 1111 1111 1111 1000 0000
addresses are given in octets -- 8 bits each:
octet 1 . octet 2 . octet 3 . octet 4
0000 0000 0000 0000 0000 0000 0000 0000
1111 1111 1111 1111 1111 1111 1000 0000
So a decimal representation of each octet is:
255 . 255 . 255 . 128
That means that your subnet mask would be:
255.255.255.128
The subnet mask is a bitmask. 25 means that 25 out of 32 bits (starting from the top) is used for the network, and the rest for the hosts.
In bytes: 128.2.19.0
In binary 10000000 00000010 00010011 00000000
The bitmask: 11111111 11111111 11111111 10000000
Ergo: ------- network ------------ host
The last 7 bits are used for hosts. The bitmask as bytes is 255.255.255.128.
Here's how you can do it in C:
#include <stdio.h>
#include <arpa/inet.h>
uint32_t cidr_to_netmask(uint8_t cidr)
{
uint8_t unset_bits = 32 - cidr;
return ntohl(0xffffffff << unset_bits);
}
int main(void)
{
uint8_t cidr = 25;
uint32_t _netmask = cidr_to_netmask(cidr);
struct in_addr _netmask_addr = { _netmask };
char netmask[16];
if (inet_ntop(AF_INET, (struct in_addr *)&_netmask_addr, (char *)&netmask, sizeof(netmask)) == NULL) {
fprintf(stderr, "error.\n");
return 1;
}
printf("%d = %s\n", cidr, netmask);
return 0;
}
Output:
25 = 255.255.255.128