I2S Input configuration Beaglebone ALSA - device-driver

I am trying to capture sound from a Circular Microphone Board (TIDA-01454) in a Beaglebone AI. I have succesfully configured the ADCs of the CMB via I2C, and checked that the I2S output is working correctly with an external DAC.
However my next step is to capture this I2S into my Beaglebone AI in order to process it later. I think I have configured the pins correctly following this guide and this document. So my show-pins is like this:
And my DTS file is like this:
#include "am5729-beagleboneai.dts"
// make it easy to determine which dtb you're currently running on
// (via /proc/device-tree/chosen/)
/ {
chosen {
base_dtb = "am5729-beagleboneai-custom.dts";
base_dtb_timestamp = __TIMESTAMP__;
};
};
// eventually these should be available in a header
#define P9_14 (0x3400 + 4 * 107)
#define P9_16 (0x3400 + 4 * 108)
#define P9_19a (0x3400 + 4 * 16)
#define P9_19b (0x3400 + 4 * 95)
#define P9_20a (0x3400 + 4 * 17)
#define P9_20b (0x3400 + 4 * 94)
#define P9_12 (0x3400 + 4 * 171)
#define P9_27b (0x3400 + 4 * 172)
#define P9_18b (0x3400 + 4 * 173)
//
/{
pcm5102a: pcm5102a {
#sound-dai-cells = <0>;
compatible = "ti,pcm5102a";
status = "okay";
};
sound {compatible = "simple-audio-card";
simple-audio-card,format = "i2s";
simple-audio-card,name = "PCM5102a";
simple-audio-card,bitclock-master = <&sound1_master>;
simple-audio-card,frame-master = <&sound1_master>;
simple-audio-card,bitclock-inversion;
simple-audio-card,cpu {
sound-dai = <&mcasp1>;
};
sound1_master: simple-audio-card,codec {
#sound-dai-cells = <0>;
sound-dai = <&pcm5102a>;
};
};
};
// enable i2c-3 on P9.19 (scl) + P9.20 (sda)
&i2c4 {
status = "okay";
clock-frequency = <400000>;
pinctrl-names = "default";
pinctrl-0 = <&i2c4_pins>;
};
&mcasp1 {
#sound-dai-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&mcasp1_pins>;
op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>;
num-serializer = <4>;
/* 16 serializers */
serial-dir = < /* 1 TX 2 RX 0 unused */
2 0 0 0
>;
rx-num-evt = <1>;
tx-num-evt = <1>;
};
&dra7_pmx_core {
i2c4_pins: i2c4 {
pinctrl-single,pins = <
DRA7XX_CORE_IOPAD( P9_19a, PIN_INPUT_PULLUP | MUX_MODE7 ) // scl
DRA7XX_CORE_IOPAD( P9_19b, PIN_INPUT_PULLUP | MUX_MODE14 ) // (shared pin)
DRA7XX_CORE_IOPAD( P9_20a, PIN_INPUT_PULLUP | MUX_MODE7 ) // sda
DRA7XX_CORE_IOPAD( P9_20b, PIN_INPUT_PULLUP | MUX_MODE14 ) // (shared pin)
>;
};
mcasp1_pins: mcasp1_pins {
pinctrl-single,pins = <
DRA7XX_CORE_IOPAD(P9_12, PIN_INPUT_PULLDOWN | MUX_MODE0) // 12 0 mcasp1_aclkr BIT CLOCK BCLK
DRA7XX_CORE_IOPAD(P9_27b, PIN_INPUT | MUX_MODE0) // 27b 0 mcasp1_fsr FRAME SYNC LRCLK
DRA7XX_CORE_IOPAD(P9_18b, PIN_INPUT | MUX_MODE0) // 18b 0 mcasp1_axr0 I2S INPUT DATA
>;
};
};
// enable pwm-2 on P9.14 (out-A) + P9.16 (out-B)
&epwmss2 {
status = "okay";
};
&ehrpwm2 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&ehrpwm2_pins>;
};
&dra7_pmx_core {
ehrpwm2_pins: ehrpwm2 {
pinctrl-single,pins = <
DRA7XX_CORE_IOPAD( P9_14, PIN_OUTPUT_PULLDOWN | MUX_MODE10 ) // out A
DRA7XX_CORE_IOPAD( P9_16, PIN_OUTPUT_PULLDOWN | MUX_MODE10 ) // out B
>;
};
};
However I think it doesn't detect it as a capture device. Since the grep and arecord command return this:
debian#beaglebone:/var/lib/cloud9$ dmesg |grep sound
[ 1.385258] asoc-simple-card sound: pcm5102a-hifi <-> 48460000.mcasp mapping ok
debian#beaglebone:/var/lib/cloud9$ arecord -l
**** List of CAPTURE Hardware Devices ****
debian#beaglebone:/var/lib/cloud9$
I think there might be a problem with ALSA configuration, but I am new into this and I dont know how to do it.
My ALSA version is: Advanced Linux Sound Architecture Driver Version k4.14.108-ti-r143.
And my sound cards are:
cat /proc/asound/cards
0 [Black ]: TI_BeagleBone_B - TI BeagleBone Black
TI BeagleBone Black
So the card is not detected? Is it ALSA or driver problem? How can I do it?

Related

TLV VLAN corrupted or missing for STP via scapy

i need to generate an STP traffic but when I capture it via wireshark it says that tlv (tag-length-value) of the vlan is missing and tlv record is truncated prematurely
this is my code:
sendp(Dot3(dst="01:00:0c:cc:cc:cd", src="08:17:35:51:29:2e")/LLC(dsap=0xaa, ssap=0xaa, ctrl=3)/SNAP(OUI=0x0c, code=0x010b)/STP(rootid=8406, portid=0x802e, pathcost=19, rootmac="2c:33:11:53:85:80",bridgeid=32982, bridgemac="08:17:35:51:29:00")/data)
I added Dot1Q(vlan=214) =>
the data in root identifier and bridge identifier changed, which is not desired and a new problem appeared as shown in the picture above
so what should I add/delete in my line of code to overcome the tlv vlan problem?
I think taht you need to replace the layer Dot3 by Ether
here are 3 exemples:
your original, scapy seems happy
what I think you did (I inferred from "I added Dot1Q(vlan=214) =>")
replace of Dot3 by Ether
for the 3 exemples:
from scapy.layers.inet import SNAP
from scapy.layers.l2 import Ether, Dot3, Dot1Q, LLC, STP
data = "test"
exemple number 1:
packet = (
Dot3(dst="01:00:0c:cc:cc:cd", src="08:17:35:51:29:2e")
/ LLC(dsap=0xAA, ssap=0xAA, ctrl=3)
/ SNAP(OUI=0x0C, code=0x010B)
/ STP(
rootid=8406,
portid=0x802E,
pathcost=19,
rootmac="2c:33:11:53:85:80",
bridgeid=32982,
bridgemac="08:17:35:51:29:00",
)
/ data
)
packet.show2()
output:
###[ 802.3 ]###
dst = 01:00:0c:cc:cc:cd
src = 08:17:35:51:29:2e
len = 47
###[ LLC ]###
dsap = 0xaa
ssap = 0xaa
ctrl = 3
###[ SNAP ]###
OUI = 0xc
code = 0x10b
###[ Spanning Tree Protocol ]###
proto = 0
version = 0
bpdutype = 0
bpduflags = 0
rootid = 8406
rootmac = 2c:33:11:53:85:80
pathcost = 19
bridgeid = 32982
bridgemac = 08:17:35:51:29:00
portid = 32814
age = 1.0
maxage = 20.0
hellotime = 2.0
fwddelay = 15.0
###[ Raw ]###
load = 'test'
exemple number 2:
vlan_packet = (
Dot3(dst="01:00:0c:cc:cc:cd", src="08:17:35:51:29:2e")
/ Dot1Q(vlan=214)
/ LLC(dsap=0xAA, ssap=0xAA, ctrl=3)
/ SNAP(OUI=0x0C, code=0x010B)
/ STP(
rootid=8406,
portid=0x802E,
pathcost=19,
rootmac="2c:33:11:53:85:80",
bridgeid=32982,
bridgemac="08:17:35:51:29:00",
)
/ data
)
vlan_packet.show2()
output:
###[ 802.3 ]###
dst = 01:00:0c:cc:cc:cd
src = 08:17:35:51:29:2e
len = 51
###[ LLC ]###
dsap = 0x0
ssap = 0xd6
ctrl = 136
###[ Raw ]###
load = 'p\xaa\xaa\x03\x00\x00\x0c\x01\x0b\x00\x00\x00\x00\x00 \xd6,3\x11S\x85\x80\x00\x00\x00\x13\x80\xd6\x08\x175Q)\x00\x80.\x01\x00\x14\x00\x02\x00\x0f\x00test'
=> see how scapy is confused by this packet?
what I think you need to send:
exemple 3:
vlan_packet = (
Ether(dst="01:00:0c:cc:cc:cd", src="08:17:35:51:29:2e")
/ Dot1Q(vlan=214)
/ LLC(dsap=0xAA, ssap=0xAA, ctrl=3)
/ SNAP(OUI=0x0C, code=0x010B)
/ STP(
rootid=8406,
portid=0x802E,
pathcost=19,
rootmac="2c:33:11:53:85:80",
bridgeid=32982,
bridgemac="08:17:35:51:29:00",
)
/ data
)
vlan_packet.show2()
output:
###[ Ethernet ]###
dst = 01:00:0c:cc:cc:cd
src = 08:17:35:51:29:2e
type = n_802_1Q
###[ 802.1Q ]###
prio = 0
id = 0
vlan = 214
type = 0x8870
###[ LLC ]###
dsap = 0xaa
ssap = 0xaa
ctrl = 3
###[ SNAP ]###
OUI = 0xc
code = 0x10b
###[ Spanning Tree Protocol ]###
proto = 0
version = 0
bpdutype = 0
bpduflags = 0
rootid = 8406
rootmac = 2c:33:11:53:85:80
pathcost = 19
bridgeid = 32982
bridgemac = 08:17:35:51:29:00
portid = 32814
age = 1.0
maxage = 20.0
hellotime = 2.0
fwddelay = 15.0
###[ Raw ]###
load = 'test'
scapy looks happier

How to detect recurrent patterns in a textfile

To simplify a function with many terms, a program would be useful that searches for patterns in a file and arranges them in a ranking list. I can imagine that this is an elaborate process, but I'm sure there are people who have built something like this.
An example of a text:
sin(t1)*cos(t1)*t1+t1-sin(t1)*sin(t1-pi)
This should give me such an output like this (min. 2 letters):
6x: "t1"
4x: "(t1"
3x: "n(t1"
3x: "sin"
3x: "sin("
2x: "sin(t1)"
etc.
Does this problem have a name (which I don't know)? Is there a known algorithm that could solve the problem for me?
I have written a small program with QT, which fulfills the task. The approach is to try everything. To solve my problem, it will probably take a few days, because the text files are very large.
If I have the following text as input ("text.txt"):
sin(t1)*cos(t1)*t1+t1-sin(t1)*sin(t1-pi)
I have with the parameters: length 2-5, minimum occurrence: 3
following result:
t1 6
(t 4
(t1 4
si 3
in 3
n( 3
1) 3
)* 3
sin 3
in( 3
n(t 3
t1) 3
1)* 3
sin( 3
in(t 3
n(t1 3
(t1) 3
t1)* 3
sin(t 3
in(t1 3
(t1)* 3
Code:
#include <QCoreApplication>
#include <qdebug.h>
#include <qstring.h>
#include <qfile.h>
#include <qtextstream.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString * wholefile = new QString;
uint64_t minchar = 2;
uint64_t maxchar = 5;
uint64_t min_occur = 3;
QFile file("text.txt");
if(!file.open(QIODevice::ReadOnly)) {
qDebug()<<"error reading file";
}
QTextStream in(&file);
while(!in.atEnd()) {
QString line = in.readLine();
wholefile->append(line);
}
file.close();
QStringList * allpatterns = new QStringList;
for(uint64_t i=minchar; i<=maxchar;i++){
for(uint64_t pos=0; pos<wholefile->length()-i;pos++){
QString pattern = wholefile->mid(pos,i);
if(allpatterns->contains(pattern)==0){
allpatterns->append(pattern);
}
}
}
uint64_t * strcnt = new uint64_t[allpatterns->length()];
uint64_t maximum_cnt = 0;
QStringList * interestingpatterns = new QStringList;
uint64_t nr_of_patterns = 0;
for(uint64_t i=0; i<allpatterns->length();i++){
QString str = allpatterns->at(i);
strcnt[nr_of_patterns] = wholefile->count(str);
if(strcnt[nr_of_patterns]>=min_occur){
if(strcnt[nr_of_patterns]>maximum_cnt){
maximum_cnt = strcnt[nr_of_patterns];
}
interestingpatterns->append(str);
nr_of_patterns++;
}
}
/* display result*/
QFile file2("out.txt");
if (!file2.open(QIODevice::WriteOnly | QIODevice::Text))
qDebug()<<"error writing file";
QTextStream out(&file2);
uint64_t current_max = maximum_cnt;
while(current_max>=min_occur){
for(uint64_t i=0; i<interestingpatterns->length();i++){
if(strcnt[i]==current_max){
QString str = interestingpatterns->at(i);
qDebug()<<str<<strcnt[i];
out <<str<<" "<< QString::number(strcnt[i])<<"\n";
}
}
current_max--;
}
file2.close();
return a.exec();
}

What should I do if I have seven segment pins in different ports?

In my circuit, 7 segment pins is in different port like:Seg A to SegD (in RA0 to RA4) SegE(in RF1) SegF (RG4) SegG(RG3). I can count 0 to 9 with setting bits one by one. I need to count 0-9999 but ı can't store values. How can ı do that for my specs?
#include "mcc_generated_files/mcc.h"
#define DISP1 RD7
#define DISP2 RD6
#define DISP3 RD5
#define DISP4 RD4
#define SEGA RA0
#define SEGB RA1
#define SEGC RA2
#define SEGD RA3
#define SEGE RF1
#define SEGF RG4
#define SEGG RG3
void main(void)
{
// initialize the device
SYSTEM_Initialize();
TRISD = 0x00; // Set All Pins To Be Output Pins
PORTD = 0x00; // Initially Clear All The 8-Pins
while(1)
{
SEGA=1;SEGB=1;SEGC=1;SEGD=1;SEGE=1;SEGF=1;SEGG=0;DISP4=1;//0
__delay_ms(500);
SEGA=0;SEGB=1;SEGC=1;SEGD=0;SEGE=0;SEGF=0;SEGG=0;DISP4=1;//1
__delay_ms(500);
SEGA=1;SEGB=1;SEGC=0;SEGD=1;SEGE=1;SEGF=0;SEGG=1;DISP4=1;//2
__delay_ms(500);
SEGA=1;SEGB=1;SEGC=1;SEGD=1;SEGE=0;SEGF=0;SEGG=1;DISP4=1;//3
__delay_ms(500);
SEGA=0;SEGB=1;SEGC=1;SEGD=0;SEGE=0;SEGF=1;SEGG=1;DISP4=1;//4
__delay_ms(500);
SEGA=1;SEGB=0;SEGC=1;SEGD=1;SEGE=0;SEGF=1;SEGG=1;DISP4=1;//5
__delay_ms(500);
SEGA=1;SEGB=0;SEGC=1;SEGD=1;SEGE=1;SEGF=1;SEGG=1;DISP4=1;//6
__delay_ms(500);
SEGA=1;SEGB=1;SEGC=1;SEGD=0;SEGE=0;SEGF=0;SEGG=0;DISP4=1;//7
__delay_ms(500);
SEGA=1;SEGB=1;SEGC=1;SEGD=1;SEGE=1;SEGF=1;SEGG=1;DISP4=1;//8
__delay_ms(500);
SEGA=1;SEGB=1;SEGC=1;SEGD=1;SEGE=0;SEGF=1;SEGG=1;DISP4=1;//9
__delay_ms(500);
}
Some hints:
If you want 4 digits, you had to multiplex your display.
Write a table where you define each number:
const uint8_t LEDTable[10] = {0b00111111, //led drive for 0
0b00000110, //led drive for 1
....
0b01101101}; //led drive for 9
Do the multiplexing in an interrupt routine.
In the interrupt you had to do the output for each digit:
ones
tens
hunderts...
The output for each digit could look like:
SEGA = (value & 0x01) ? 1:0;
SEGB = (value & 0x02) ? 1:0;
SEGC = (value & 0x04) ? 1:0;
SEGD = ...

OLED Test for USBSTK5515 with CCSv6

I am trying to run the test code for the OLED display simulation on the DSP board TMSC320C5515 eZdsp UsbStick, variant "USBSTK5515".
I have included the bsl folder and needed included libraries and header files through the spectrum website. Now the problem is that I am being unable to compile; I am getting the error:
**** Build of configuration Debug for project OLED ****
"G:\\TheDevelopmentKitCodeComposerv6\\ccsv6\\utils\\bin\\gmake" -k all
'Building file: ../main.c'
'Invoking: C5500 Compiler'
"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/bin/cl55" -v5515 --memory_model=large -g --include_path="C:/Users/SOURINDU/Desktop/usbstk5515_BSL_RevA/usbstk5515_v1/include" --include_path="C:/Users/SOURINDU/Desktop/usbstk1151_Demo_RevA/USBSTK5515_demo/source/USB_Stick_Sample/inc" --include_path="G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/include" --define=c5515 --display_error_number --diag_warning=225 --ptrdiff_size=16 --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
'Finished building: ../main.c'
' '
'Building file: ../usbstk5515bsl/bsl/usbstk5515.c'
'Invoking: C5500 Compiler'
"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/bin/cl55" -v5515 --memory_model=large -g --include_path="C:/Users/SOURINDU/Desktop/usbstk5515_BSL_RevA/usbstk5515_v1/include" --include_path="C:/Users/SOURINDU/Desktop/usbstk1151_Demo_RevA/USBSTK5515_demo/source/USB_Stick_Sample/inc" --include_path="G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/include" --define=c5515 --display_error_number --diag_warning=225 --ptrdiff_size=16 --preproc_with_compile --preproc_dependency="usbstk5515bsl/bsl/usbstk5515.pp" --obj_directory="usbstk5515bsl/bsl" "../usbstk5515bsl/bsl/usbstk5515.c"
'Finished building: ../usbstk5515bsl/bsl/usbstk5515.c'
' '
'Building file: ../usbstk5515bsl/bsl/usbstk5515_gpio.c'
'Invoking: C5500 Compiler'
"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/bin/cl55" -v5515 --memory_model=large -g --include_path="C:/Users/SOURINDU/Desktop/usbstk5515_BSL_RevA/usbstk5515_v1/include" --include_path="C:/Users/SOURINDU/Desktop/usbstk1151_Demo_RevA/USBSTK5515_demo/source/USB_Stick_Sample/inc" --include_path="G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/include" --define=c5515 --display_error_number --diag_warning=225 --ptrdiff_size=16 --preproc_with_compile --preproc_dependency="usbstk5515bsl/bsl/usbstk5515_gpio.pp" --obj_directory="usbstk5515bsl/bsl" "../usbstk5515bsl/bsl/usbstk5515_gpio.c"
'Finished building: ../usbstk5515bsl/bsl/usbstk5515_gpio.c'
' '
'Building file: ../usbstk5515bsl/bsl/usbstk5515_i2c.c'
'Invoking: C5500 Compiler'
"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/bin/cl55" -v5515 --memory_model=large -g --include_path="C:/Users/SOURINDU/Desktop/usbstk5515_BSL_RevA/usbstk5515_v1/include" --include_path="C:/Users/SOURINDU/Desktop/usbstk1151_Demo_RevA/USBSTK5515_demo/source/USB_Stick_Sample/inc" --include_path="G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/include" --define=c5515 --display_error_number --diag_warning=225 --ptrdiff_size=16 --preproc_with_compile --preproc_dependency="usbstk5515bsl/bsl/usbstk5515_i2c.pp" --obj_directory="usbstk5515bsl/bsl" "../usbstk5515bsl/bsl/usbstk5515_i2c.c"
'Finished building: ../usbstk5515bsl/bsl/usbstk5515_i2c.c'
' '
'Building file: ../usbstk5515bsl/bsl/usbstk5515_led.c'
'Invoking: C5500 Compiler'
"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/bin/cl55" -v5515 --memory_model=large -g --include_path="C:/Users/SOURINDU/Desktop/usbstk5515_BSL_RevA/usbstk5515_v1/include" --include_path="C:/Users/SOURINDU/Desktop/usbstk1151_Demo_RevA/USBSTK5515_demo/source/USB_Stick_Sample/inc" --include_path="G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/include" --define=c5515 --display_error_number --diag_warning=225 --ptrdiff_size=16 --preproc_with_compile --preproc_dependency="usbstk5515bsl/bsl/usbstk5515_led.pp" --obj_directory="usbstk5515bsl/bsl" "../usbstk5515bsl/bsl/usbstk5515_led.c"
'Finished building: ../usbstk5515bsl/bsl/usbstk5515_led.c'
' '
'Building target: OLED.out'
'Invoking: C5500 Linker'
"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/bin/cl55" -v5515 --memory_model=large -g --define=c5515 --display_error_number --diag_warning=225 --ptrdiff_size=16 -z -m"OLED.map" --stack_size=0x200 --heap_size=0x400 -i"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/lib" -i"G:/TheDevelopmentKitCodeComposerv6/ccsv6/tools/compiler/c5500_4.4.1/include" --reread_libs --display_error_number --warn_sections --xml_link_info="OLED_linkInfo.xml" --rom_model --sys_stacksize=0x200 -o "OLED.out" "./main.obj" "./usbstk5515bsl/bsl/usbstk5515.obj" "./usbstk5515bsl/bsl/usbstk5515_gpio.obj" "./usbstk5515bsl/bsl/usbstk5515_i2c.obj" "./usbstk5515bsl/bsl/usbstk5515_led.obj" "../lnkx.cmd" "../usbstk5515bsl/usbstk5515bsl.lib" -l"libc.a" -l"rts55x.lib"
<Linking>
undefined first referenced
symbol in file
--------- ----------------
_main G:\TheDevelopmentKitCodeComposerv6\ccsv6\tools\compiler\c5500_4.4.1\lib\rts55x.lib<args_main.obj>
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "OLED.out" not built
>> Compilation failure
gmake: *** [OLED.out] Error 1
gmake: Target `all' not remade because of errors.
**** Build Finished ****
And in the problem window :
Description Resource Path Location Type
#10010 errors encountered during linking; "OLED.out" not built OLED C/C++ Problem
#10234-D unresolved symbols remain OLED C/C++ Problem
unresolved symbol _main, first referenced in G:\TheDevelopmentKitCodeComposerv6\ccsv6\tools\compiler\c5500_4.4.1\lib\rts55x.lib<args_main.obj> OLED C/C++ Problem
My Code as downloaded from spectrum website is
/*
* Copyright 2010 by Spectrum Digital Incorporated.
* All rights reserved. Property of Spectrum Digital Incorporated.
*/
/*
* OSD9616 OLED Test
*
*/
#include "usbstk5515.h"
//#include "usbstk5515_led.h"
#include "usbstk5515_i2c.h"
#include "lcd.h"
#include "usbstk5515_gpio.h"
#define OSD9616_I2C_ADDR 0x3C // OSD9616 I2C address
/* ------------------------------------------------------------------------ *
* *
* Int16 OSD9616_send( Uint16 comdat, Uint16 data ) *
* *
* Sends 2 bytes of data to the OSD9616 *
* *
* ------------------------------------------------------------------------ */
Int16 OSD9616_send( Uint16 comdat, Uint16 data )
{
Uint8 cmd[2];
cmd[0] = comdat & 0x00FF; // Specifies whether data is Command or Data
cmd[1] = data; // Command / Data
return USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, 2 );
}
/* ------------------------------------------------------------------------ *
* *
* Int16 OSD9616_multiSend( Uint16 comdat, Uint16 data ) *
* *
* Sends multiple bytes of data to the OSD9616 *
* *
* ------------------------------------------------------------------------ */
Int16 OSD9616_multiSend( Uint8* data, Uint16 len )
{
Uint16 x;
Uint8 cmd[10];
for(x=0;x<len;x++) // Command / Data
{
cmd[x] = data[x];
}
return USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, len );
}
/* ------------------------------------------------------------------------ *
* *
* Int16 printLetter(Uint16 l1,Uint16 l2,Uint16 l3,Uint16 l4) *
* *
* Send 4 bytes representing a Character *
* *
* ------------------------------------------------------------------------ */
Int16 printLetter(Uint16 l1,Uint16 l2,Uint16 l3,Uint16 l4)
{
OSD9616_send(0x40,l1);
OSD9616_send(0x40,l2);
OSD9616_send(0x40,l3);
OSD9616_send(0x40,l4);
OSD9616_send(0x40,0x00);
return 0;
}
/* ------------------------------------------------------------------------ *
* *
* Int16 oled_test() *
* *
* Testing function for the OSD9616 display *
* *
* ------------------------------------------------------------------------ */
Int16 oled_test()
{
Int16 i, i2c_err;
Uint8 cmd[10]; // For multibyte commands
/* Initialize I2C */
USBSTK5515_I2C_init( );
/* Initialize LCD power */
USBSTK5515_GPIO_setDirection( 12, 1 ); // Output
USBSTK5515_GPIO_setOutput( 12, 1 ); // Enable 13V
/* Initialize OSD9616 display */
i2c_err = OSD9616_send(0x00,0x00); // Set low column address
i2c_err = OSD9616_send(0x00,0x10); // Set high column address
if(i2c_err) // Don't setup display if not connected
return 1;
OSD9616_send(0x00,0x40); // Set start line address
cmd[0] = 0x00 & 0x00FF; // Set contrast control register
cmd[1] = 0x81;
cmd[2] = 0x7f;
USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, 3 );
OSD9616_send(0x00,0xa1); // Set segment re-map 95 to 0
OSD9616_send(0x00,0xa6); // Set normal display
cmd[0] = 0x00 & 0x00FF; // Set multiplex ratio(1 to 16)
cmd[1] = 0xa8;
cmd[2] = 0x0f;
USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, 3 );
OSD9616_send(0x00,0xd3); // Set display offset
OSD9616_send(0x00,0x00); // Not offset
OSD9616_send(0x00,0xd5); // Set display clock divide ratio/oscillator frequency
OSD9616_send(0x00,0xf0); // Set divide ratio
cmd[0] = 0x00 & 0x00FF; // Set pre-charge period
cmd[1] = 0xd9;
cmd[2] = 0x22;
USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, 3 );
cmd[0] = 0x00 & 0x00FF; // Set com pins hardware configuration
cmd[1] = 0xda;
cmd[2] = 0x02;
USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, 3 );
OSD9616_send(0x00,0xdb); // Set vcomh
OSD9616_send(0x00,0x49); // 0.83*vref
cmd[0] = 0x00 & 0x00FF; //--set DC-DC enable
cmd[1] = 0x8d;
cmd[2] = 0x14;
USBSTK5515_I2C_write( OSD9616_I2C_ADDR, cmd, 3 );
OSD9616_send(0x00,0xaf); // Turn on oled panel
/* Fill page 0 */
OSD9616_send(0x00,0x00); // Set low column address
OSD9616_send(0x00,0x10); // Set high column address
OSD9616_send(0x00,0xb0+0); // Set page for page 0 to page 5
for(i=0;i<128;i++)
{
OSD9616_send(0x40,0xff);
}
/* Write to page 0 */
OSD9616_send(0x00,0x00); // Set low column address
OSD9616_send(0x00,0x10); // Set high column address
OSD9616_send(0x00,0xb0+0); // Set page for page 0 to page 5
for(i=0;i<22;i++)
{
OSD9616_send(0x40,0x00); // Spaces
}
printLetter(0x32,0x49,0x49,0x26); // S
printLetter(0x01,0x7F,0x01,0x01); // T
printLetter(0x7F,0x30,0x0E,0x7F); // N
printLetter(0x41,0x49,0x49,0x7F); // E
printLetter(0x7F,0x06,0x06,0x7F); // M
printLetter(0x3F,0x40,0x40,0x3F); // U
printLetter(0x46,0x29,0x19,0x7F); // R
printLetter(0x01,0x7F,0x01,0x01); // T
printLetter(0x32,0x49,0x49,0x26); // S
printLetter(0x7F,0x30,0x0E,0x7F); // N
printLetter(0x00,0x7F,0x00,0x00); // I
for(i=0;i<5;i++)
{
OSD9616_send(0x40,0x00); // Spaces
}
printLetter(0x32,0x49,0x49,0x26); // S
printLetter(0x7C,0x09,0x0A,0x7C); // A
printLetter(0x63,0x1C,0x1C,0x63); // X
printLetter(0x41,0x49,0x49,0x7F); // E
printLetter(0x01,0x7F,0x01,0x01); // T
for(i=0;i<23;i++)
{
OSD9616_send(0x40,0x00); // Spaces
}
/* Fill page 1*/
OSD9616_send(0x00,0x00); // Set low column address
OSD9616_send(0x00,0x10); // Set high column address
OSD9616_send(0x00,0xb0+1); // Set page for page 0 to page 5
for(i=0;i<128;i++)
{
OSD9616_send(0x40,0xff);
}
/* Write to page 1*/
OSD9616_send(0x00,0x00); // Set low column address
OSD9616_send(0x00,0x10); // Set high column address
OSD9616_send(0x00,0xb0+1); // Set page for page 0 to page 5
for(i=0;i<20;i++)
{
OSD9616_send(0x40,0x00);
}
printLetter(0x41,0x22,0x14,0x7F); // K
printLetter(0x22,0x41,0x41,0x3E); // C
printLetter(0x00,0x7F,0x00,0x00); // I
printLetter(0x01,0x7F,0x01,0x01); // T
printLetter(0x32,0x49,0x49,0x26); // S
for(i=0;i<5;i++)
{
OSD9616_send(0x40,0x00); // Spaces
}
printLetter(0x36,0x49,0x49,0x7F); // B
printLetter(0x32,0x49,0x49,0x26); // S
printLetter(0x3F,0x40,0x40,0x3F); // U
for(i=0;i<5;i++)
{
OSD9616_send(0x40,0x00); // Spaces
}
printLetter(0x06,0x09,0x09,0x7F); // P
printLetter(0x32,0x49,0x49,0x26); // S
printLetter(0x3E,0x41,0x41,0x7F); // D
printLetter(0x43,0x4D,0x51,0x61); // Z
printLetter(0x10,0x58,0x58,0x30); // e
for(i=0;i<5;i++)
{
OSD9616_send(0x40,0x00); // Spaces
}
printLetter(0x31,0x49,0x49,0x2F); // 5
printLetter(0x00,0x7F,0x00,0x00); // 1
printLetter(0x31,0x49,0x49,0x2F); // 5
printLetter(0x31,0x49,0x49,0x2F); // 5
printLetter(0x22,0x41,0x41,0x3E); // C
for(i=0;i<23;i++)
{
OSD9616_send(0x40,0x00); // Spaces
}
/* Set vertical and horizontal scrolling */
cmd[0] = 0x00;
cmd[1] = 0x29; // Vertical and Right Horizontal Scroll
cmd[2] = 0x00; // Dummy byte
cmd[3] = 0x00; // Define start page address
cmd[4] = 0x03; // Set time interval between each scroll step
cmd[5] = 0x01; // Define end page address
cmd[6] = 0x01; // Vertical scrolling offset
OSD9616_multiSend( cmd, 7 );
OSD9616_send(0x00,0x2f);
/* Keep first 8 rows from vertical scrolling */
cmd[0] = 0x00;
cmd[1] = 0xa3; // Set Vertical Scroll Area
cmd[2] = 0x08; // Set No. of rows in top fixed area
cmd[3] = 0x08; // Set No. of rows in scroll area
OSD9616_multiSend( cmd, 4 );
return 0;
}
Probably a bit late now, but I think the problem is that you don't have a main function defined to call any of the functions, hence message "unresolved symbol _main".
Not familiar with that particular board, but the example that came with my ezdspc5535 had 2 c files, one of which had a main and examples of how to call the functions in oled_test.c

Does free Xively account causes QoS 1 or 2 publish failed?

My code (below) is working if I use QoS 0. But for QoS 1 or QoS 2. MQTTClient_publishMessage(...) failed.
Am I missing any configuration? Or, is it because I am using free XIvely account?
I use Paho API.
------------------------------- start of cut -------------------------------------
/**
* #file
*
* Paho MQ Client API to Xively mqtt broker
*
*/
enter code here
#include "MQTTClient.h"
#include <stdlib.h>
void usage()
{
printf("Usage: speicify QoS\n");
printf(" turn on bulb -> ka_pub Qos 1 1\n");
printf(" turn off bulb -> ka_pub Qos 1 0\n");
printf(" send 7 to led -> ka_pub Qos 2 7\n");
printf(" send 2 to led -> ka_pub Qos 2 2\n");
}
int main(int argc, char** argv)
{
int rc = 0;
if (argc < 3) {
usage();
exit (0);
}
char TOPIC[250] ; // given enough space first to avoid malloc
MQTTClient client;
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
MQTTClient_message pubmsg = MQTTClient_message_initializer;
MQTTClient_deliveryToken token;
int QoS = atoi(argv[1]);
if (argv[2][0] == '1') {
strcpy(TOPIC, BULB_TOPIC);
conn_opts.username = BULB_API_KEY ;
conn_opts.password = "" ; // will be ignored
} else
if (argv[2][0] == '2') {
strcpy(TOPIC, LED_TOPIC) ;
conn_opts.username = LED_API_KEY ;
conn_opts.password = "" ; // will be ignored
} else {
printf("Bad arg\n");
usage();
exit (0);
}
setenv("MQTT_C_CLIENT_TRACE", "ON", 1); // same as 'stdout'
setenv("MQTT_C_CLIENT_TRACE_LEVEL", "ERROR", 1); //ERROR, PROTOCOL, MINIMUM, MEDIUM and MAXIMUM
MQTTClient_create(&client, XIVELY_END_URL, "test", MQTTCLIENT_PERSISTENCE_DEFAULT, NULL);
//conn_opts.keepAliveInterval = 20; // init to 60
//conn_opts.cleansession = 1; // default 1, will clean previous msg in server
conn_opts.reliable = 0 ; //default 1, only 1 can in-flight, 0 - allow 10 msg
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(-1);
}
// prepare publish msg
char tmsg[250] ; // check max 250 boundary later
if (argv[2][0] == '1')
sprintf(tmsg, "{\"id\":\"switch\",\"current_value\":\"%c\"}", argv[3][0]);
else
sprintf(tmsg, "{\"id\":\"num\",\"current_value\":\"%c\"}", argv[3][0]) ;
int tmsg_len = strlen(tmsg);
pubmsg.payload = &tmsg[0] ;
pubmsg.payloadlen = tmsg_len; //mlen
pubmsg.qos = QoS;
pubmsg.retained = 0;
MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token);
//MQTTClient_publish(client, TOPIC, pubmsg.payloadlen, pubmsg.payload,
// pubmsg.qos, pubmsg.retained, &token);
rc = MQTTClient_waitForCompletion(client, token, 100000);
printf("Finish publish for TOPIC: %s, QoS: %d, msg of '%s'\n", TOPIC, pubmsg.qos, (char *) pubmsg.payload);
if (rc == 0)
MyLog(LOGA_INFO, "verdict pass");
else
MyLog(LOGA_INFO, "verdict fail");
MQTTClient_disconnect(client, 10000);
MQTTClient_destroy(&client);
return rc;
}
------------------------------- end of cut -------------------------------------
I don't believe Xively supports QoS>0.

Resources